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);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);
Also in Java:
- java how to serialize a file into a local server
- java custom color
- boolean checkbox swing
- java stack
- java loop
- How to draw Bezier Curve in Android
- how to create gravity in java
- javafx fill tableview with data
- change brightness of image in java
- java android edit text set value
- vector in java
- vertical traversal of binary tree
- capcitor FERR_CLEARTEXT_NOT_PERMITTED
- spigot actionbar
- arrays.aslist.add
- null pointer exception java
- guess the number java
- java replace element in list
- java get keys from hashmap
- how to change the color of a menubar in java
- java tester si un caractere est une lettre
- java convert string with commas to long
- bukkit scheduled task
- java remove double spaces