26- java的String 转json

时间:2022-07-04 08:58:37

https://www.cnblogs.com/nihaorz/p/5885307.html

Gjson 下载:https://download.csdn.net/download/qq_39451578/10908642

import com.google.gson.JsonObject;
import com.google.gson.JsonParser; public class Main {
public static void main(String[] args) {
String jsonMessage = "{\"语文\":\"88\",\"数学\":\"78\",\"计算机\":\"99\"}"; JsonObject returnData = new JsonParser().parse(jsonMessage).getAsJsonObject();
System.out.println(returnData);
System.out.println(returnData.get("语文"));
} }