[英]How to parse JSON String to String in Java
I have a JSON string, how can I parse it and just get the valueString in java?我有一个 JSON 字符串,如何解析它并获取 java 中的 valueString?
{
"resourceType": "Bundle",
"id": "0",
"entry": [
{
"resource": {
"resourceType": "Basic",
"extension": [
{
"url": "http://ith.sahra.com/extensions#uploadid",
"valueString": "1589355494289_655"
}
]
}
}
]
} }
This is my code, I tried to call extension I got null but I got response while calling entry这是我的代码,我尝试拨打分机我得到了 null 但我在调用 entry 时得到了响应
public static String ParsingValue(String valuepass) throws org.json.simple.parser.ParseException{
Object obj = new JSONParser().parse(valuepass);
JSONObject jo = (JSONObject) obj;
//JSONArray msg = (JSONArray) jo.getClass();
JSONArray result = (JSONArray) jo.get("entry");
}
The easiest way to parse a string through Jackson parser通过Jackson解析器解析字符串的最简单方法
Eg:例如:
ObjectMapper mapper = new ObjectMapper();
String json = "{\"name\":\"anshul\",\"age\":29}";
Map<String, Object> map = mapper.readValue(json, Map.class);
Try this, it should solve your problem.试试这个,它应该可以解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.