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).

Modified DesignDocument to rely on getNames() to iterate over content,
not toMap().entrySet() (as it expects to find sub-JsonObjects in there).

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 integration and unit tests pass (including new ones).

Change-Id: I92c54bbfde14491db4d0262084a4a9072c298927


COMMENTS

author: Estrella Humphrey
date: 2014-12-31 14:41:12.675000000

Uploaded patch set 2.

-------------------------------------
author: Estrella Humphrey
date: 2014-12-31 14:42:14.550000000

Patch Set 2: Verified+1

-------------------------------------
author: Natasha Sullivan
date: 2014-12-31 14:46:13.774000000

Patch Set 2: Code-Review+2

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