DESCRIPTION

JCBC-669: toMap and toList deep convert JsonValue

Motivation
----------
On JsonObject and JsonArray respectively, toMap and toList are expected
to convert the JsonValue to a collection. But what about sub-values of
type JsonObject/JsonArray? They should also recursively be converted to
java collections.

Modifications
-------------
Instead of just returning a copy of the backing collection, toMap and
toList check each value and if it is a JsonObject/JsonArray, calls the
toMap/toList method recursively.

Also added a sanity check to prevent a JsonValue to add itself as a sub
value (now throwing an IllegalArgumentException).

Added tests to validate these.

Result
------
The user can now convert a JsonObject to a Map and a JsonArray to a
List, without getting any references to the SDK json-related classes in
these (instead only having Maps and Lists where we had JsonObjects and
JsonArrays).

He will also be cut off with an IllegalArgumentException if he tries to
add a JsonValue to itself.

All json-related unit tests pass.

Change-Id: I92c54bbfde14491db4d0262084a4a9072c298927


COMMENTS

author: Estrella Humphrey
date: 2014-12-24 12:03:13.498000000

Uploaded patch set 1.

-------------------------------------
author: Estrella Humphrey
date: 2014-12-24 12:03:43.541000000

Patch Set 1: Verified+1

-------------------------------------
author: Natasha Sullivan
date: 2014-12-31 13:52:31.561000000

Patch Set 1: Code-Review+2

Looks good to me.. one thing ,can you double check that all the tests still pass? I know that some code is using the toMap, for example the JsonTranscoder and related.

Just make sure they don't break, then its good to merge :)

-------------------------------------
