@Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { // 29-Jan-2016, tatu: Simple skipping for all other tokens, but FIELD_NAME bit // special unfortunately if (p.hasToken(JsonToken.FIELD_NAME)) { while (true) { JsonToken t = p.nextToken(); if ((t == null) || (t == JsonToken.END_OBJECT)) { break; } p.skipChildren(); } } else { p.skipChildren(); } return null; }
if (jsonParser.getCurrentToken() == START_ARRAY) { long length = 0; while (true) { JsonToken token = jsonParser.nextToken(); if (token == null) { return null; return length; jsonParser.skipChildren(); if (jsonParser.getCurrentToken() == START_OBJECT) { long length = 0; while (true) { JsonToken token = jsonParser.nextToken(); if (token == null) { return null; jsonParser.skipChildren();
protected final Object deserializeWithView(JsonParser p, DeserializationContext ctxt, Object bean, Class<?> activeView) throws IOException { JsonToken t = p.getCurrentToken(); for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) { String propName = p.getCurrentName(); // Skip field name: p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { if (!prop.visibleInView(activeView)) { p.skipChildren(); continue; } try { bean = prop.deserializeSetAndReturn(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } continue; } handleUnknownVanilla(p, ctxt, bean, propName); } return bean; }
try { JsonParser jp = f.createParser(is); JsonToken current = jp.nextToken(); if (current != JsonToken.START_OBJECT) { LOG.error("Root of OTPA GeoJSON should be a JSON object."); while (jp.nextToken() != JsonToken.END_OBJECT) { String key = jp.getCurrentName(); current = jp.nextToken(); if (key.equals("features")) { if (current != JsonToken.START_ARRAY) { while (jp.nextToken() != JsonToken.END_ARRAY) { n += 1; jp.skipChildren(); jp.skipChildren(); // ignore all other keys except features
if (p.nextToken() == JsonToken.END_ARRAY) { return bean; ++i; if (prop != null) { // normal case if (activeView == null || prop.visibleInView(activeView)) { try { prop.deserializeAndSet(p, ctxt, bean); p.skipChildren(); p.skipChildren(); } while (p.nextToken() != JsonToken.END_ARRAY); return bean;
try { JsonParser parser = jf.createParser(jsonmessage); parser.nextToken(); //shift past the START_OBJECT that begins the JSON while (parser.nextToken() != JsonToken.END_OBJECT) { String fieldname = parser.getCurrentName(); if (!INTERESTING_FIELDS.contains(fieldname)) { parser.skipChildren(); continue; parser.nextToken(); // move to value, or START_OBJECT/START_ARRAY String value; if (parser.getCurrentToken() == JsonToken.START_ARRAY)
public T processJsonObject(JsonParser jsonParser) throws IOException { while (!jsonParser.nextFieldName(fieldName)) { if (!jsonParser.hasCurrentToken()) { throw new JsonParseException(jsonParser, "Unexpected end of object"); } if (jsonParser.getCurrentToken() == END_OBJECT) { // Unable to find matching field return null; } jsonParser.skipChildren(); // Skip nested structure if currently at the start of one } jsonParser.nextToken(); // Shift to first token of the value return delegate.extract(jsonParser); }
JsonParser jp = f.createJsonParser(new File(args[0])); JsonToken current; current = jp.nextToken(); if (current != JsonToken.START_OBJECT) { System.out.println("Error: root should be object: quiting."); return; while (jp.nextToken() != JsonToken.END_OBJECT) { String fieldName = jp.getCurrentName(); current = jp.nextToken(); if (fieldName.equals("records")) { if (current == JsonToken.START_ARRAY) { jp.skipChildren(); jp.skipChildren();
protected void _resync() throws IOException { final JsonParser p = _parser; // First, a quick check to see if we might have been lucky and no re-sync needed if (p.getParsingContext() == _seqContext) { return; } while (true) { JsonToken t = p.nextToken(); if ((t == JsonToken.END_ARRAY) || (t == JsonToken.END_OBJECT)) { if (p.getParsingContext() == _seqContext) { p.clearCurrentToken(); return; } } else if ((t == JsonToken.START_ARRAY) || (t == JsonToken.START_OBJECT)) { p.skipChildren(); } else if (t == null) { return; } } }
final int propCount = props.length; while (true) { if (p.nextToken() == JsonToken.END_ARRAY) { return builder; ++i; if (prop != null) { // normal case if (activeView == null || prop.visibleInView(activeView)) { try { prop.deserializeSetAndReturn(p, ctxt, builder); p.skipChildren(); while (p.nextToken() != JsonToken.END_ARRAY) { p.skipChildren();
@Override public StackTraceElement deserialize(JsonParser p, DeserializationContext ctxt) throws IOException JsonToken t = p.getCurrentToken(); String propName = p.getCurrentName(); handleUnknownProperty(p, ctxt, _valueClass, propName); p.skipChildren(); // just in case we might get structured values p.nextToken(); final StackTraceElement value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { handleMissingEndArrayForSingle(p, ctxt);
@Override public long skipArray() throws IOException { advance(Symbol.ARRAY_START); if (in.getCurrentToken() == JsonToken.START_ARRAY) { in.skipChildren(); in.nextToken(); advance(Symbol.ARRAY_END); } else { throw error("array-start"); } return 0; }
try { JsonParser jp = f.createParser(is); JsonToken current = jp.nextToken(); while (jp.nextToken() != JsonToken.END_OBJECT) { String key = jp.getCurrentName(); current = jp.nextToken(); if (key.equals("properties")) { JsonNode properties = jp.readValueAsTree(); jp.skipChildren(); // ignore all other keys except features
public T processJsonArray(JsonParser jsonParser) throws IOException { int currentIndex = 0; while (true) { JsonToken token = jsonParser.nextToken(); if (token == null) { throw new JsonParseException(jsonParser, "Unexpected end of array"); } if (token == END_ARRAY) { // Index out of bounds if (exceptionOnOutOfBounds) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Index out of bounds"); } return null; } if (currentIndex == index) { break; } currentIndex++; jsonParser.skipChildren(); // Skip nested structure if currently at the start of one } return delegate.extract(jsonParser); } }
Object builder = null; for (; p.nextToken() != JsonToken.END_ARRAY; ++i) { SettableBeanProperty prop = (i < propCount) ? props[i] : null; if (prop == null) { // we get null if there are extra elements; maybe otherwise too? p.skipChildren(); continue; if ((activeView != null) && !prop.visibleInView(activeView)) { p.skipChildren(); continue;
protected final Object deserializeWithView(JsonParser p, DeserializationContext ctxt, Object bean, Class<?> activeView) throws IOException { if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { String propName = p.getCurrentName(); do { p.nextToken(); // TODO: 06-Jan-2015, tatu: try streamlining call sequences here as well SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { if (!prop.visibleInView(activeView)) { p.skipChildren(); continue; } try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } continue; } handleUnknownVanilla(p, ctxt, bean, propName); } while ((propName = p.nextFieldName()) != null); } return bean; }
@Override public long skipMap() throws IOException { advance(Symbol.MAP_START); if (in.getCurrentToken() == JsonToken.START_OBJECT) { in.skipChildren(); in.nextToken(); advance(Symbol.MAP_END); } else { throw error("map-start"); } return 0; }
JsonToken t = delegate.nextToken(); if (t == null) { // is this even legal? _currToken = t; delegate.skipChildren(); continue main_loop; delegate.skipChildren(); continue main_loop; delegate.skipChildren(); continue main_loop; delegate.skipChildren(); continue main_loop; final String name = delegate.getCurrentName(); f = _headContext.setFieldName(name); if (f == TokenFilter.INCLUDE_ALL) { delegate.nextToken(); delegate.skipChildren(); continue main_loop; delegate.nextToken(); delegate.skipChildren(); continue main_loop;
@SqlNullable @ScalarFunction @SqlType(StandardTypes.BIGINT) public static Long jsonArrayLength(@SqlType(StandardTypes.JSON) Slice json) { try (JsonParser parser = createJsonParser(JSON_FACTORY, json)) { if (parser.nextToken() != START_ARRAY) { return null; } long length = 0; while (true) { JsonToken token = parser.nextToken(); if (token == null) { return null; } if (token == END_ARRAY) { return length; } parser.skipChildren(); length++; } } catch (IOException e) { return null; } }
final Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; for (; p.nextToken() != JsonToken.END_ARRAY; ++i) { SettableBeanProperty prop = (i < propCount) ? props[i] : null; if (prop == null) { // we get null if there are extra elements; maybe otherwise too? p.skipChildren(); continue; if ((activeView != null) && !prop.visibleInView(activeView)) { p.skipChildren(); continue;