JSON转对象
public static void main(String[] args) {
String res = "{"json":"https://www.sojson.com/simple_json.html","keywords":"json在线解析","goneng":["错误提示",{"beizhu":["www.sojson.com","json.la"]}]}";
// String res = "{"keywords":"hello","goneng":["hai","hai2"]}";
// String res2 = "{"keywords":"hello","goneng":"hai"}";
// JSONObject jsonArray = JSON.parseObject(res,UJson.class);
// JSONObject jsonObject1 = JSONObject.parseObject(res);
// JSONArray jsonArray = new JSONArray();
// jsonArray.add(jsonObject1);
UJson uJson = JSONObject.parseObject(res, UJson.class);
}
}
@Data
class UJson{
String keywords;
List goneng;
}

浙公网安备 33010602011771号