0

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!

1
  • 4
    Can you supply an example JSON to help us know what you're trying to parse? Commented Dec 21, 2014 at 7:28

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you provide a link to the specification? Preferably with the section you are referencing cited in your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.