Better JsonDocument handling.

Change-Id: I36d8e5338b70f1bd1347571a063fac2e09e94d9b
Reviewed-on: http://review.couchbase.org/36843
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>