com.couchbase.lite.support.JsonDocument Maven / Gradle / Ivy
package com.couchbase.lite.support;
import com.couchbase.lite.Database;
import com.couchbase.lite.Manager;
import com.couchbase.lite.util.Log;
/**
* A wrapper around a json byte array that will parse the data
* as lat as possible
*/
public class JsonDocument {
private final byte[] json;
private Object cached = null;
public JsonDocument(byte[] json) {
this.json = json;
}
//Return a JSON object from the json data
//If the Json starts with '{' or a '[' then no parsing takes place and the
//data is wrapped in a LazyJsonObject or a LazyJsonArray which will delay parsing until
//values are requested
public Object jsonObject() {
if (json == null) {
return null;
}
if (cached == null) {
Object tmp = null;
if (json[0] == '{') {
tmp = new LazyJsonObject(json);
} else if (json[0] == '[') {
tmp = new LazyJsonArray
© 2015 - 2025 Weber Informatics LLC | Privacy Policy