Makoto
Makoto

Reputation: 1475

How to check if JsonObject has specified String

Ok so I'm dealing with a Json Object that is composed of menus and sub menus. The things is that sometimes there isn't any sub menus.

So how to check if the JsonObject has a specified String (Submenu)? For the moment it just throws a JsonExeption.

Thx!

Upvotes: 0

Views: 176

Answers (1)

grig
grig

Reputation: 847

It has a method for check (docs):

JSONObject object = new JSONObject();
object.has(your_string);

Quote:

public boolean has (String name)

Returns true if this object has a mapping for name. The mapping may be NULL.

Upvotes: 1

Related Questions