我需要从动态json中获取键的值.
Input-> json Object,String key
Output-> json element(对应键的值)
示例
JsonObject Jmsg =
{
"id": "1753_CORE1",
"name": "Gtx cuda Service:1753",
"shortName": "gt-service-1753",
"createdDate": "Mar 31, 2015 4:47:10 PM",
"config": {
"oauthSecret": [
{
"id": 45,
"config123": {
"oauthSecret": "P8n2x5Hsst0nFRRB0A",
"status": "CREATED"
},
"SERVER132": "1000"
},
{
"id": 46,
"config123": {
"oauthSecret": "P8n2x5Htss0nFRRB0A"
},
"SERVER132": "1000"
}
],
"oauthKey": "154284-service-1753",
"SERVER": "1000"
},
"features": [
9004,
9005
]
}
Run Code Online (Sandbox Code Playgroud)
和String key ="status";
然后JsonElement Jvalue = jsonGetValueformKey(Jmsg,key);
应该在JsonElement或字符串类型中返回'CREATED'.
if String key ="features";
然后 …