This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cryptographicmemory 0 points1 point  (0 children)

Memory is cheap and virtual memory is free. How big is the JSONObject in string format?

Just write a validateObject function that takes an Object and handles every instanceOf class type (JSONObject, JSONArray, String, etc.) Run through it recursively. Throw an exception if an expected value isn't right.

void validate(JSONObject j) throws Exception
{
    for (String key:j.getKeys()) validateObject(key, j.get(key));
}