所以,我从服务器获取了一些JSON值,但我不知道是否会有特定的字段.
所以喜欢:
{ "regatta_name":"ProbaRegatta",
"country":"Congo",
"status":"invited"
}
Run Code Online (Sandbox Code Playgroud)
有时,会有一个额外的字段,如:
{ "regatta_name":"ProbaRegatta",
"country":"Congo",
"status":"invited",
"club":"somevalue"
}
Run Code Online (Sandbox Code Playgroud)
我想检查名为"club"的字段是否存在,以便在解析时我不会得到org.json.JSONException:没有俱乐部的价值