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
Reviewed-on: http://review.couchbase.org/44642
Tested-by: Estrella Humphrey xxx@xxx.xxx
Reviewed-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Estrella Humphrey
date: 2014-12-31 14:48:05.105000000

Change has been successfully cherry-picked as bbe06dc88e325d04a58f228c11109cb91c72ae83

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