📜  gson 解析 json - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:42.648000             🧑  作者: Mango

代码示例1
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);