check if json key has value java code example
Example 1: json object check if key exists java
// JSONObject class has a method named "has":
// http://developer.android.com/reference/org/json/JSONObject.html
// Returns true if this object has a mapping for name. The mapping may be NULL.
if (json.has("status")) {
String status = json.getString("status"));
}
if (json.has("club")) {
String club = json.getString("club"));
}
Example 2: how to check if json has a key python
b_in_dict = "b" in a_dictionary