Answers for "gson parse json"

-1

gson parse json

Gson gson = new Gson();

// 1. JSON file to Java object
Object object = gson.fromJson(new FileReader("C:\\fileName.json"), Object.class);

// 2. JSON string to Java object
String json = "{'name' : 'mkyong'}";
Object object = gson.fromJson(json, Staff.class);
Posted by: Guest on May-14-2020
-1

gson parse json

Gson gson = new Gson();

// 1. Java object to JSON file
gson.toJson(obj, new FileWriter("C:\\fileName.json"));

// 2. Java object to JSON string
String json = gson.toJson(obj);
Posted by: Guest on May-14-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language