List of usage examples for com.fasterxml.jackson.core JsonToken START_OBJECT
JsonToken START_OBJECT
To view the source code for com.fasterxml.jackson.core JsonToken START_OBJECT.
Click Source Link
From source file:com.github.shyiko.jackson.module.advice.AdvisedBeanDeserializer.java
@SuppressWarnings("resource") protected Object deserializeWithUnwrapped(JsonParser jp, DeserializationContext ctxt, Object bean) throws IOException { JsonToken t = jp.getCurrentToken();/*from ww w.j a v a 2 s.co m*/ if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } TokenBuffer tokens = new TokenBuffer(jp); tokens.writeStartObject(); final Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; beanDeserializerAdvice.before(bean, jp, ctxt); for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) { String propName = jp.getCurrentName(); if (beanDeserializerAdvice.intercept(bean, propName, jp, ctxt)) { continue; } SettableBeanProperty prop = _beanProperties.find(propName); jp.nextToken(); if (prop != null) { // normal case if (activeView != null && !prop.visibleInView(activeView)) { jp.skipChildren(); continue; } try { prop.deserializeAndSet(jp, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } continue; } if (_ignorableProps != null && _ignorableProps.contains(propName)) { handleIgnoredProperty(jp, ctxt, bean, propName); continue; } // but... others should be passed to unwrapped property deserializers tokens.writeFieldName(propName); tokens.copyCurrentStructure(jp); // how about any setter? We'll get copies but... if (_anySetter != null) { _anySetter.deserializeAndSet(jp, ctxt, bean, propName); } } tokens.writeEndObject(); _unwrappedPropertyHandler.processUnwrapped(jp, ctxt, bean, tokens); beanDeserializerAdvice.after(bean, jp, ctxt); return bean; }
From source file:pl.selvin.android.syncframework.content.BaseContentProvider.java
protected boolean Sync(String service, String scope, String params) { final Date start = new Date(); boolean hasError = false; if (params == null) params = ""; final SQLiteDatabase db = mDB.getWritableDatabase(); final ArrayList<TableInfo> notifyTableInfo = new ArrayList<TableInfo>(); final String download = String.format(contentHelper.DOWNLOAD_SERVICE_URI, service, scope, params); final String upload = String.format(contentHelper.UPLOAD_SERVICE_URI, service, scope, params); final String scopeServerBlob = String.format("%s.%s.%s", service, scope, _.serverBlob); String serverBlob = null;/*from w w w . j av a 2 s . c o m*/ Cursor cur = db.query(BlobsTable.NAME, new String[] { BlobsTable.C_VALUE }, BlobsTable.C_NAME + "=?", new String[] { scopeServerBlob }, null, null, null); final String originalBlob; if (cur.moveToFirst()) { originalBlob = serverBlob = cur.getString(0); } else { originalBlob = null; } cur.close(); db.beginTransaction(); try { boolean nochanges = false; if (serverBlob != null) { nochanges = !contentHelper.hasDirtTable(db, scope); } boolean resolve = false; final Metadata meta = new Metadata(); final HashMap<String, Object> vals = new HashMap<String, Object>(); final ContentValues cv = new ContentValues(2); JsonFactory jsonFactory = new JsonFactory(); JsonToken current = null; String name = null; boolean moreChanges = false; boolean forceMoreChanges = false; do { final int requestMethod; final String serviceRequestUrl; final ContentProducer contentProducer; if (serverBlob != null) { requestMethod = HTTP_POST; if (nochanges) { serviceRequestUrl = download; } else { serviceRequestUrl = upload; forceMoreChanges = true; } contentProducer = new SyncContentProducer(jsonFactory, db, scope, serverBlob, !nochanges, notifyTableInfo, contentHelper); nochanges = true; } else { requestMethod = HTTP_GET; serviceRequestUrl = download; contentProducer = null; } if (moreChanges) { db.beginTransaction(); } Result result = executeRequest(requestMethod, serviceRequestUrl, contentProducer); if (result.getStatus() == HttpStatus.SC_OK) { final JsonParser jp = jsonFactory.createParser(result.getInputStream()); jp.nextToken(); // skip ("START_OBJECT(d) expected"); jp.nextToken(); // skip ("FIELD_NAME(d) expected"); if (jp.nextToken() != JsonToken.START_OBJECT) throw new Exception("START_OBJECT(d - object) expected"); while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); if (_.__sync.equals(name)) { current = jp.nextToken(); while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); current = jp.nextToken(); if (_.serverBlob.equals(name)) { serverBlob = jp.getText(); } else if (_.moreChangesAvailable.equals(name)) { moreChanges = jp.getBooleanValue() || forceMoreChanges; forceMoreChanges = false; } else if (_.resolveConflicts.equals(name)) { resolve = jp.getBooleanValue(); } } } else if (_.results.equals(name)) { if (jp.nextToken() != JsonToken.START_ARRAY) throw new Exception("START_ARRAY(results) expected"); while (jp.nextToken() != JsonToken.END_ARRAY) { meta.isDeleted = false; meta.tempId = null; vals.clear(); while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); current = jp.nextToken(); if (current == JsonToken.VALUE_STRING) { vals.put(name, jp.getText()); } else if (current == JsonToken.VALUE_NUMBER_INT) { vals.put(name, jp.getLongValue()); } else if (current == JsonToken.VALUE_NUMBER_FLOAT) { vals.put(name, jp.getDoubleValue()); } else if (current == JsonToken.VALUE_FALSE) { vals.put(name, 0L); } else if (current == JsonToken.VALUE_TRUE) { vals.put(name, 1L); } else if (current == JsonToken.VALUE_NULL) { vals.put(name, null); } else { if (current == JsonToken.START_OBJECT) { if (_.__metadata.equals(name)) { while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); jp.nextToken(); if (_.uri.equals(name)) { meta.uri = jp.getText(); } else if (_.type.equals(name)) { meta.type = jp.getText(); } else if (_.isDeleted.equals(name)) { meta.isDeleted = jp.getBooleanValue(); } else if (_.tempId.equals(name)) { meta.tempId = jp.getText(); } } } else if (_.__syncConflict.equals(name)) { while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); jp.nextToken(); if (_.isResolved.equals(name)) { } else if (_.conflictResolution.equals(name)) { } else if (_.conflictingChange.equals(name)) { while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); current = jp.nextToken(); if (current == JsonToken.START_OBJECT) { if (_.__metadata.equals(name)) { while (jp.nextToken() != JsonToken.END_OBJECT) { } } } } } } // resolve conf } else if (_.__syncError.equals(name)) { while (jp.nextToken() != JsonToken.END_OBJECT) { name = jp.getCurrentName(); jp.nextToken(); } } } } } TableInfo tab = contentHelper.getTableFromType(meta.type); if (meta.isDeleted) { tab.DeleteWithUri(meta.uri, db); } else { tab.SyncJSON(vals, meta, db); } if (!notifyTableInfo.contains(tab)) notifyTableInfo.add(tab); } } } jp.close(); if (!hasError) { cv.clear(); cv.put(BlobsTable.C_NAME, scopeServerBlob); cv.put(BlobsTable.C_VALUE, serverBlob); cv.put(BlobsTable.C_DATE, Calendar.getInstance().getTimeInMillis()); cv.put(BlobsTable.C_STATE, 0); db.replace(BlobsTable.NAME, null, cv); db.setTransactionSuccessful(); db.endTransaction(); if (DEBUG) { Log.d(TAG, "CP-Sync: commit changes"); } final ContentResolver cr = getContext().getContentResolver(); for (TableInfo t : notifyTableInfo) { final Uri nu = contentHelper.getDirUri(t.name, false); cr.notifyChange(nu, null, false); // false - do not force sync cause we are in sync if (DEBUG) { Log.d(TAG, "CP-Sync: notifyChange table: " + t.name + ", uri: " + nu); } for (String n : t.notifyUris) { cr.notifyChange(Uri.parse(n), null, false); if (DEBUG) { Log.d(TAG, "+uri: " + n); } } } notifyTableInfo.clear(); } } else { if (DEBUG) { Log.e(TAG, "Server error in fetching remote contacts: " + result.getStatus()); } hasError = true; break; } } while (moreChanges); } catch (final ConnectTimeoutException e) { hasError = true; if (DEBUG) { Log.e(TAG, "ConnectTimeoutException", e); } } catch (final IOException e) { hasError = true; if (DEBUG) { Log.e(TAG, Log.getStackTraceString(e)); } } catch (final ParseException e) { hasError = true; if (DEBUG) { Log.e(TAG, "ParseException", e); } } catch (final Exception e) { hasError = true; if (DEBUG) { Log.e(TAG, "ParseException", e); } } if (hasError) { db.endTransaction(); ContentValues cv = new ContentValues(); cv.put(BlobsTable.C_NAME, scopeServerBlob); cv.put(BlobsTable.C_VALUE, originalBlob); cv.put(BlobsTable.C_DATE, Calendar.getInstance().getTimeInMillis()); cv.put(BlobsTable.C_STATE, -1); db.replace(BlobsTable.NAME, null, cv); } /*-if (!hasError) { final ContentValues cv = new ContentValues(2); cv.put(BlobsTable.C_NAME, scopeServerBlob); cv.put(BlobsTable.C_VALUE, serverBlob); db.replace(BlobsTable.NAME, null, cv); db.setTransactionSuccessful(); } db.endTransaction(); if (!hasError) { for (String t : notifyTableInfo) { getContext().getContentResolver().notifyChange(getDirUri(t), null); } }*/ if (DEBUG) { Helpers.LogInfo(start); } return !hasError; }
From source file:com.bazaarvoice.jackson.rison.RisonParser.java
private JsonToken _nextAfterName() { _nameCopied = false; // need to invalidate if it was copied JsonToken t = _nextToken;//from w w w . ja va2 s. c o m _nextToken = null; // Also: may need to start new context? if (t == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return (_currToken = t); }
From source file:com.netflix.hollow.jsonadapter.HollowJsonAdapter.java
private void skipSubArray(JsonParser parser) throws IOException { JsonToken token = parser.nextToken(); while (token != JsonToken.END_ARRAY) { if (token == JsonToken.START_OBJECT) { skipObject(parser);/* w ww.j a v a 2 s . com*/ } else { skipObjectField(parser, token); } token = parser.nextToken(); } }
From source file:com.adobe.communities.ugc.migration.importer.UGCImportHelper.java
protected void extractTopic(final JsonParser jsonParser, final Resource resource, final ResourceResolver resolver, final CommentOperations operations) throws IOException, ServletException { if (jsonParser.getCurrentToken().equals(JsonToken.END_OBJECT)) { return; // replies could just be an empty object (i.e. "ugc:replies":{} ) in which case, do nothing }/* ww w .j a va 2s .c o m*/ final Map<String, Object> properties = new HashMap<String, Object>(); properties.put("social:key", jsonParser.getCurrentName()); Resource post = null; jsonParser.nextToken(); if (jsonParser.getCurrentToken().equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); String author = null; List<DataSource> attachments = new ArrayList<DataSource>(); while (!jsonParser.getCurrentToken().equals(JsonToken.END_OBJECT)) { final String label = jsonParser.getCurrentName(); JsonToken token = jsonParser.nextToken(); if (jsonParser.getCurrentToken().isScalarValue()) { // either a string, boolean, or long value if (token.isNumeric()) { properties.put(label, jsonParser.getValueAsLong()); } else { final String value = jsonParser.getValueAsString(); if (value.equals("true") || value.equals("false")) { properties.put(label, jsonParser.getValueAsBoolean()); } else { final String decodedValue = URLDecoder.decode(value, "UTF-8"); if (label.equals("language")) { properties.put("mtlanguage", decodedValue); } else { properties.put(label, decodedValue); if (label.equals("userIdentifier")) { author = decodedValue; } else if (label.equals("jcr:description")) { properties.put("message", decodedValue); } } } } } else if (label.equals(ContentTypeDefinitions.LABEL_ATTACHMENTS)) { attachments = getAttachments(jsonParser); } else if (label.equals(ContentTypeDefinitions.LABEL_REPLIES) || label.equals(ContentTypeDefinitions.LABEL_TALLY) || label.equals(ContentTypeDefinitions.LABEL_TRANSLATION) || label.equals(ContentTypeDefinitions.LABEL_SUBNODES)) { // replies and sub-nodes ALWAYS come after all other properties and attachments have been listed, // so we can create the post now if we haven't already, and then dive in if (post == null) { try { post = createPost(resource, author, properties, attachments, resolver.adaptTo(Session.class), operations); resProvider = SocialResourceUtils.getSocialResource(post).getResourceProvider(); } catch (Exception e) { throw new ServletException(e.getMessage(), e); } } if (label.equals(ContentTypeDefinitions.LABEL_REPLIES)) { if (token.equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); while (!token.equals(JsonToken.END_OBJECT)) { extractTopic(jsonParser, post, resolver, operations); token = jsonParser.nextToken(); } } else { throw new IOException("Expected an object for the subnodes"); } } else if (label.equals(ContentTypeDefinitions.LABEL_SUBNODES)) { if (token.equals(JsonToken.START_OBJECT)) { token = jsonParser.nextToken(); try { while (!token.equals(JsonToken.END_OBJECT)) { final String subnodeType = jsonParser.getCurrentName(); token = jsonParser.nextToken(); if (token.equals(JsonToken.START_OBJECT)) { jsonParser.skipChildren(); token = jsonParser.nextToken(); } } } catch (final IOException e) { throw new IOException("unable to skip child of sub-nodes", e); } } else { final String field = jsonParser.getValueAsString(); throw new IOException("Expected an object for the subnodes. Instead: " + field); } } else if (label.equals(ContentTypeDefinitions.LABEL_TALLY)) { UGCImportHelper.extractTally(post, jsonParser, resProvider, tallyOperationsService); } else if (label.equals(ContentTypeDefinitions.LABEL_TRANSLATION)) { importTranslation(jsonParser, post); resProvider.commit(post.getResourceResolver()); } } else if (jsonParser.getCurrentToken().equals(JsonToken.START_OBJECT)) { properties.put(label, UGCImportHelper.extractSubmap(jsonParser)); } else if (jsonParser.getCurrentToken().equals(JsonToken.START_ARRAY)) { jsonParser.nextToken(); // skip the START_ARRAY token if (label.equals(ContentTypeDefinitions.LABEL_TIMESTAMP_FIELDS)) { while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) { final String timestampLabel = jsonParser.getValueAsString(); if (properties.containsKey(timestampLabel) && properties.get(timestampLabel) instanceof Long) { final Calendar calendar = new GregorianCalendar(); calendar.setTimeInMillis((Long) properties.get(timestampLabel)); properties.put(timestampLabel, calendar.getTime()); } jsonParser.nextToken(); } } else { final List<String> subArray = new ArrayList<String>(); while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) { subArray.add(jsonParser.getValueAsString()); jsonParser.nextToken(); } String[] strings = new String[subArray.size()]; for (int i = 0; i < subArray.size(); i++) { strings[i] = subArray.get(i); } properties.put(label, strings); } } jsonParser.nextToken(); } if (post == null) { try { post = createPost(resource, author, properties, attachments, resolver.adaptTo(Session.class), operations); if (null == resProvider) { resProvider = SocialResourceUtils.getSocialResource(post).getResourceProvider(); } // resProvider.commit(resolver); } catch (Exception e) { throw new ServletException(e.getMessage(), e); } } } else { throw new IOException("Improperly formed JSON - expected an OBJECT_START token, but got " + jsonParser.getCurrentToken().toString()); } }
From source file:com.bazaarvoice.jackson.rison.RisonParser.java
@Override public String nextTextValue() throws IOException, JsonParseException { if (_currToken == JsonToken.FIELD_NAME) { // mostly copied from '_nextAfterName' _nameCopied = false;//from w w w . ja v a2 s .c o m JsonToken t = _nextToken; _nextToken = null; _currToken = t; if (t == JsonToken.VALUE_STRING) { if (_tokenIncomplete) { _tokenIncomplete = false; _finishString(); } return _textBuffer.contentsAsString(); } if (t == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } // !!! TODO: optimize this case as well return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null; }
From source file:org.apache.lucene.server.handlers.AddDocumentHandler.java
/** Parse one value for a field, which is either an * object matching the type of the field, or a {boost: * ..., value: ...}. *//*from ww w .j a v a2 s . c o m*/ private static boolean parseOneValue(FieldDef fd, JsonParser p, Document doc) throws IOException { Object o = null; float boost = 1.0f; JsonToken token = p.nextToken(); if (token == JsonToken.START_ARRAY) { if ("hierarchy".equals(fd.faceted) || fd.valueType == FieldDef.FieldValueType.LAT_LON) { o = getNativeValue(fd, token, p); } else { if (fd.multiValued == false) { fail(fd.name, "expected single value, not array, since this field is not multiValued"); } while (true) { if (!parseOneValue(fd, p, doc)) { break; } } return true; } } else { if (token == JsonToken.END_ARRAY) { assert fd.multiValued; return false; } if (fd.fieldType.indexOptions() != IndexOptions.NONE && token == JsonToken.START_OBJECT) { // Parse a {boost: X, value: Y} while (true) { token = p.nextToken(); if (token == JsonToken.END_OBJECT) { break; } assert token == JsonToken.FIELD_NAME; String key = p.getText(); if (key.equals("boost")) { token = p.nextToken(); if (token == JsonToken.VALUE_NUMBER_INT || token == JsonToken.VALUE_NUMBER_FLOAT) { boost = p.getFloatValue(); } else { fail(fd.name, "boost in inner object field value must have float or int value; got: " + token); } } else if (key.equals("value")) { o = getNativeValue(fd, p.nextToken(), p); } else { fail(fd.name, "unrecognized json key \"" + key + "\" in inner object field value; must be boost or value"); } } if (o == null) { fail(fd.name, "missing 'value' key"); } } else { // Parse a native value: o = getNativeValue(fd, token, p); } } parseOneNativeValue(fd, doc, o, boost); return true; }
From source file:com.bazaarvoice.jackson.rison.RisonParser.java
@Override public int nextIntValue(int defaultValue) throws IOException, JsonParseException { if (_currToken == JsonToken.FIELD_NAME) { _nameCopied = false;/*from ww w .jav a2 s. co m*/ JsonToken t = _nextToken; _nextToken = null; _currToken = t; if (t == JsonToken.VALUE_NUMBER_INT) { return getIntValue(); } if (t == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } // !!! TODO: optimize this case as well return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue; }
From source file:com.zenesis.qx.remote.RequestHandler.java
/** * Handles dynamic changes to a qa.data.Array instance without having a complete replacement; expects a * serverId, propertyName, type (one of "add", "remove", "order"), start, end, and optional array of items * @param jp//w ww .j ava 2 s. c o m * @throws ServletException * @throws IOException */ protected void cmdEditArray(JsonParser jp) throws ServletException, IOException { // Get the basics int serverId = getFieldValue(jp, "serverId", Integer.class); String propertyName = getFieldValue(jp, "propertyName", String.class); String action = getFieldValue(jp, "type", String.class); Integer start = null; Integer end = null; if (!action.equals("replaceAll")) { start = getFieldValue(jp, "start", Integer.class); end = getFieldValue(jp, "end", Integer.class); } // Get our info Proxied serverObject = getProxied(serverId); ProxyType type = ProxyTypeManager.INSTANCE.getProxyType(serverObject.getClass()); ProxyProperty prop = getProperty(type, propertyName); if (prop.getPropertyClass().isMap()) { Map items = null; // Get the optional array of items if (jp.nextToken() == JsonToken.FIELD_NAME && jp.getCurrentName().equals("items") && jp.nextToken() == JsonToken.START_OBJECT) { items = readMap(jp, prop.getPropertyClass().getKeyClass(), prop.getPropertyClass().getJavaType()); } // Quick logging if (log.isInfoEnabled()) { String str = ""; if (items != null) for (Object key : items.keySet()) { if (str.length() > 0) str += ", "; str += String.valueOf(key) + "=" + String.valueOf(items.get(key)); } log.info("edit-array: property=" + prop + ", type=" + action + ", start=" + start + ", end=" + end + str); } if (action.equals("replaceAll")) { Map map = (Map) prop.getValue(serverObject); if (map == null) { try { map = (Map) prop.getPropertyClass().getCollectionClass().newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e.getMessage(), e); } prop.setValue(serverObject, map); } map.clear(); map.putAll(items); } else throw new IllegalArgumentException("Unsupported action in cmdEditArray: " + action); // Because collection properties are objects and we change them without the serverObject's // knowledge, we have to make sure we notify other trackers ourselves ProxyManager.propertyChanged(serverObject, propertyName, items, null); jp.nextToken(); } else { // NOTE: items is an Array!! But because it may be an array of primitive types, we have // to use java.lang.reflect.Array to access members because we cannot cast arrays of // primitives to Object[] Object items = null; // Get the optional array of items if (jp.nextToken() == JsonToken.FIELD_NAME && jp.getCurrentName().equals("items") && jp.nextToken() == JsonToken.START_ARRAY) { items = readArray(jp, prop.getPropertyClass().getJavaType()); } int itemsLength = Array.getLength(items); // Quick logging if (log.isInfoEnabled()) { String str = ""; if (items != null) for (int i = 0; i < itemsLength; i++) { if (str.length() != 0) str += ", "; str += Array.get(items, i); } log.info("edit-array: property=" + prop + ", type=" + action + ", start=" + start + ", end=" + end + str); } if (action.equals("replaceAll")) { if (prop.getPropertyClass().isCollection()) { Collection list = (Collection) prop.getValue(serverObject); if (list == null) { try { list = (Collection) prop.getPropertyClass().getCollectionClass().newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e.getMessage(), e); } prop.setValue(serverObject, list); } list.clear(); if (items != null) for (int i = 0; i < itemsLength; i++) list.add(Array.get(items, i)); // Because collection properties are objects and we change them without the serverObject's // knowledge, we have to make sure we notify other trackers ourselves ProxyManager.propertyChanged(serverObject, propertyName, list, null); } else { prop.setValue(serverObject, items); } } else throw new IllegalArgumentException("Unsupported action in cmdEditArray: " + action); jp.nextToken(); } }
From source file:com.microsoft.windowsazure.storage.table.TableParser.java
/** * Reserved for internal use. Parses the operation response as a collection of entities. Reads entity data from the * specified input stream using the specified class type and optionally projects each entity result with the * specified resolver into an {@link ODataPayload} containing a collection of {@link TableResult} objects. * //www . j a va 2 s . c o m * @param inStream * The <code>InputStream</code> to read the data to parse from. * @param clazzType * The class type <code>T</code> implementing {@link TableEntity} for the entities returned. Set to * <code>null</code> to ignore the returned entities and copy only response properties into the * {@link TableResult} objects. * @param resolver * An {@link EntityResolver} instance to project the entities into instances of type <code>R</code>. Set * to <code>null</code> to return the entities as instances of the class type <code>T</code>. * @param opContext * An {@link OperationContext} object used to track the execution of the operation. * @return * An {@link ODataPayload} containing a collection of {@link TableResult} objects with the parsed operation * response. * @throws ParseException * if an error occurs while parsing the stream. * @throws InstantiationException * if an error occurs while constructing the result. * @throws IllegalAccessException * if an error occurs in reflection while parsing the result. * @throws StorageException * if a storage service error occurs. * @throws IOException * if an error occurs while accessing the stream. * @throws JsonParseException * if an error occurs while parsing the stream. */ @SuppressWarnings("unchecked") private static <T extends TableEntity, R> ODataPayload<?> parseJsonQueryResponse(final InputStream inStream, final Class<T> clazzType, final EntityResolver<R> resolver, final TableRequestOptions options, final OperationContext opContext) throws ParseException, InstantiationException, IllegalAccessException, StorageException, JsonParseException, IOException { ODataPayload<T> corePayload = null; ODataPayload<R> resolvedPayload = null; ODataPayload<?> commonPayload = null; JsonParser parser = createJsonParserFromStream(inStream); try { if (resolver != null) { resolvedPayload = new ODataPayload<R>(); commonPayload = resolvedPayload; } else { corePayload = new ODataPayload<T>(); commonPayload = corePayload; } if (!parser.hasCurrentToken()) { parser.nextToken(); } ODataUtilities.assertIsStartObjectJsonToken(parser); // move into data parser.nextToken(); // if there is a clazz type and if JsonNoMetadata, create a classProperties dictionary to use for type inference once // instead of querying the cache many times HashMap<String, PropertyPair> classProperties = null; if (options.getTablePayloadFormat() == TablePayloadFormat.JsonNoMetadata && clazzType != null) { classProperties = PropertyPair.generatePropertyPairs(clazzType); } while (parser.getCurrentToken() != null) { if (parser.getCurrentToken() == JsonToken.FIELD_NAME && parser.getCurrentName().equals(ODataConstants.VALUE)) { // move to start of array parser.nextToken(); ODataUtilities.assertIsStartArrayJsonToken(parser); // go to properties parser.nextToken(); while (parser.getCurrentToken() == JsonToken.START_OBJECT) { final TableResult res = parseJsonEntity(parser, clazzType, classProperties, resolver, options, opContext); if (corePayload != null) { corePayload.tableResults.add(res); } if (resolver != null) { resolvedPayload.results.add((R) res.getResult()); } else { corePayload.results.add((T) res.getResult()); } parser.nextToken(); } ODataUtilities.assertIsEndArrayJsonToken(parser); } parser.nextToken(); } } finally { parser.close(); } return commonPayload; }