List of usage examples for org.springframework.data.couchbase.core.mapping CouchbaseDocument CouchbaseDocument
public CouchbaseDocument()
From source file:org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService.java
/** * Helper method to decode an object recursively. * * @param parser the JSON parser with the content. * @param target the target where the content should be stored. * * @throws IOException// ww w . j a v a 2s . c om * @returns the decoded object. */ private CouchbaseDocument decodeObject(final JsonParser parser, final CouchbaseDocument target) throws IOException { JsonToken currentToken = parser.nextToken(); String fieldName = ""; while (currentToken != null && currentToken != JsonToken.END_OBJECT) { if (currentToken == JsonToken.START_OBJECT) { target.put(fieldName, decodeObject(parser, new CouchbaseDocument())); } else if (currentToken == JsonToken.START_ARRAY) { target.put(fieldName, decodeArray(parser, new CouchbaseList())); } else if (currentToken == JsonToken.FIELD_NAME) { fieldName = parser.getCurrentName(); } else { target.put(fieldName, decodePrimitive(currentToken, parser)); } currentToken = parser.nextToken(); } return target; }
From source file:org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService.java
/** * Helper method to decode an array recusrively. * * @param parser the JSON parser with the content. * @param target the target where the content should be stored. * * @throws IOException// ww w .ja v a2s. co m * @returns the decoded list. */ private CouchbaseList decodeArray(final JsonParser parser, final CouchbaseList target) throws IOException { JsonToken currentToken = parser.nextToken(); while (currentToken != null && currentToken != JsonToken.END_ARRAY) { if (currentToken == JsonToken.START_OBJECT) { target.put(decodeObject(parser, new CouchbaseDocument())); } else if (currentToken == JsonToken.START_ARRAY) { target.put(decodeArray(parser, new CouchbaseList())); } else { target.put(decodePrimitive(currentToken, parser)); } currentToken = parser.nextToken(); } return target; }