List of usage examples for com.fasterxml.jackson.core JsonParser getCurrentName
public abstract String getCurrentName() throws IOException, JsonParseException;
From source file:org.labkey.freezerpro.export.FreezerProCommandResonse.java
/** * Position the parser to the start of the data array object * @param parser//from ww w .java 2 s . co m * @param dataNodeName * @return * @throws IOException */ protected boolean ensureDataNode(JsonParser parser, String dataNodeName) throws IOException { JsonToken token = parser.nextToken(); //JsonUtil.expectObjectStart(parser); while (token != JsonToken.END_OBJECT) { token = parser.nextToken(); if (token == JsonToken.FIELD_NAME) { String fieldName = parser.getCurrentName(); if (dataNodeName.equals(fieldName)) { parser.nextToken(); return true; } else if (TOTAL_FIELD_NAME.equalsIgnoreCase(fieldName)) { JsonToken totalToken = parser.nextToken(); if (totalToken == JsonToken.VALUE_NUMBER_INT) { _totalRecords = parser.readValueAs(Integer.class); } } } } return false; }
From source file:com.netflix.hollow.jsonadapter.discover.HollowJsonAdapterSchemaDiscoverer.java
private void discoverSchemas(JsonParser parser, HollowDiscoveredSchema schema) throws IOException { JsonToken token = parser.nextToken(); while (token != JsonToken.END_OBJECT) { String fieldName = parser.getCurrentName(); //if (isDebug) parser = print("discoverSchemas fieldName=" + fieldName, token, parser); discoverSchemaField(parser, token, fieldName, schema); token = parser.nextToken();//from w ww . j a v a 2 s . co m } }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.FunctionImportDeserializer.java
@Override public FunctionImport deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImport funcImp = new FunctionImport(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { funcImp.setName(jp.nextTextValue()); } else if ("ReturnType".equals(jp.getCurrentName())) { funcImp.setReturnType(jp.nextTextValue()); } else if ("EntitySet".equals(jp.getCurrentName())) { funcImp.setEntitySet(jp.nextTextValue()); } else if ("EntitySetPath".equals(jp.getCurrentName())) { funcImp.setEntitySetPath(jp.nextTextValue()); } else if ("IsComposable".equals(jp.getCurrentName())) { funcImp.setComposable(Boolean.valueOf(jp.nextTextValue())); } else if ("IsSideEffecting".equals(jp.getCurrentName())) { funcImp.setSideEffecting(Boolean.valueOf(jp.nextTextValue())); } else if ("IsBindable".equals(jp.getCurrentName())) { funcImp.setBindable(Boolean.valueOf(jp.nextTextValue())); } else if ("IsAlwaysBindable".equals(jp.getCurrentName())) { funcImp.setAlwaysBindable(Boolean.valueOf(jp.nextTextValue())); } else if ("HttpMethod".equals(jp.getCurrentName())) { funcImp.setHttpMethod(jp.nextTextValue()); } else if ("Parameter".equals(jp.getCurrentName())) { jp.nextToken();/* w ww .j a v a 2s .c o m*/ funcImp.getParameters().add(jp.getCodec().readValue(jp, Parameter.class)); } } } return funcImp; }
From source file:com.ntsync.shared.RawContact.java
private static RawOrganizationData readOrg(String rowId, JsonParser jp) throws IOException { String orgname = null;//from ww w. ja va2 s . c o m OrganizationType orgtype = null; String orgLabel = null; String department = null; String jobTitle = null; String title = null; boolean isSuperPrimary = false; boolean isPrimary = false; while (jp.nextToken() != JsonToken.END_OBJECT) { String namefield = jp.getCurrentName(); // move to value if (jp.nextToken() == null) { throw new JsonParseException("Invalid JSON-Structure. End of Object missing.", jp.getCurrentLocation()); } if (ContactConstants.DATA.equals(namefield)) { orgname = jp.getValueAsString(); } else if (ContactConstants.TYPE.equals(namefield)) { orgtype = OrganizationType.fromVal(jp.getValueAsInt()); } else if (ContactConstants.PRIMARY.equals(namefield)) { isPrimary = jp.getValueAsBoolean(); } else if (ContactConstants.SUPERPRIMARY.equals(namefield)) { isSuperPrimary = jp.getValueAsBoolean(); } else if (ContactConstants.LABEL.equals(namefield)) { orgLabel = jp.getValueAsString(); } else if (ContactConstants.ORGANIZATION_DEPARTMENT.equals(namefield)) { department = jp.getValueAsString(); } else if (ContactConstants.ORGANIZATION_TITLE.equals(namefield)) { title = jp.getValueAsString(); } else if (ContactConstants.ORGANIZATION_JOB.equals(namefield)) { jobTitle = jp.getValueAsString(); } else { LOG.error("Unrecognized Organization-field for row with Id:" + rowId + " Fieldname:" + namefield); } } if (orgtype == null) { orgtype = OrganizationType.TYPE_OTHER; } return new RawOrganizationData(orgname, orgtype, orgLabel, isPrimary, isSuperPrimary, title, department, jobTitle); }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v3.FunctionImportDeserializer.java
@Override protected FunctionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImport funcImp = new FunctionImport(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { funcImp.setName(jp.nextTextValue()); } else if ("ReturnType".equals(jp.getCurrentName())) { funcImp.setReturnType(jp.nextTextValue()); } else if ("EntitySet".equals(jp.getCurrentName())) { funcImp.setEntitySet(jp.nextTextValue()); } else if ("EntitySetPath".equals(jp.getCurrentName())) { funcImp.setEntitySetPath(jp.nextTextValue()); } else if ("IsComposable".equals(jp.getCurrentName())) { funcImp.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsSideEffecting".equals(jp.getCurrentName())) { funcImp.setSideEffecting(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsBindable".equals(jp.getCurrentName())) { funcImp.setBindable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsAlwaysBindable".equals(jp.getCurrentName())) { funcImp.setAlwaysBindable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("HttpMethod".equals(jp.getCurrentName())) { funcImp.setHttpMethod(jp.nextTextValue()); } else if ("Parameter".equals(jp.getCurrentName())) { jp.nextToken();/* ww w . ja va 2 s . co m*/ funcImp.getParameters().add(jp.getCodec().readValue(jp, Parameter.class)); } } } return funcImp; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.SchemaDeserializer.java
@Override public Schema deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final Schema schema = new Schema(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Namespace".equals(jp.getCurrentName())) { schema.setNamespace(jp.nextTextValue()); } else if ("Alias".equals(jp.getCurrentName())) { schema.setAlias(jp.nextTextValue()); } else if ("Using".equals(jp.getCurrentName())) { jp.nextToken();/* w w w.j av a 2 s .c o m*/ schema.getUsings().add(jp.getCodec().readValue(jp, Using.class)); } else if ("Association".equals(jp.getCurrentName())) { jp.nextToken(); schema.getAssociations().add(jp.getCodec().readValue(jp, Association.class)); } else if ("ComplexType".equals(jp.getCurrentName())) { jp.nextToken(); schema.getComplexTypes().add(jp.getCodec().readValue(jp, ComplexType.class)); } else if ("EntityType".equals(jp.getCurrentName())) { jp.nextToken(); schema.getEntityTypes().add(jp.getCodec().readValue(jp, EntityType.class)); } else if ("EnumType".equals(jp.getCurrentName())) { jp.nextToken(); schema.getEnumTypes().add(jp.getCodec().readValue(jp, EnumType.class)); } else if ("ValueTerm".equals(jp.getCurrentName())) { jp.nextToken(); schema.getValueTerms().add(jp.getCodec().readValue(jp, ValueTerm.class)); } else if ("EntityContainer".equals(jp.getCurrentName())) { jp.nextToken(); schema.getEntityContainers().add(jp.getCodec().readValue(jp, EntityContainer.class)); } else if ("Annotations".equals(jp.getCurrentName())) { jp.nextToken(); schema.getAnnotations().add(jp.getCodec().readValue(jp, Annotations.class)); } } } return schema; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.TypeDefinitionDeserializer.java
@Override protected TypeDefinition doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final TypeDefinition typeDefinition = new TypeDefinition(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { typeDefinition.setName(jp.nextTextValue()); } else if ("UnderlyingType".equals(jp.getCurrentName())) { typeDefinition.setUnderlyingType(jp.nextTextValue()); } else if ("MaxLength".equals(jp.getCurrentName())) { typeDefinition.setMaxLength(jp.nextTextValue()); } else if ("Unicode".equals(jp.getCurrentName())) { typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Precision".equals(jp.getCurrentName())) { typeDefinition.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("Scale".equals(jp.getCurrentName())) { typeDefinition.setScale(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("SRID".equals(jp.getCurrentName())) { typeDefinition.setSrid(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken();/*from w w w. java2 s .c o m*/ typeDefinition.getAnnotations().add(jp.getCodec().readValue(jp, Annotation.class)); } } } return typeDefinition; }
From source file:org.hyperledger.dropwizard.hocon.HoconDeserializer.java
protected ConfigObject deserializeObject(JsonParser jp, DeserializationContext ctxt) throws IOException { HashMap<String, Object> mapping = new HashMap<>(); while (jp.nextToken() != JsonToken.END_OBJECT) { String name = jp.getCurrentName(); JsonToken t = jp.nextToken();/* w w w.j a v a2s . c o m*/ switch (t) { case START_ARRAY: mapping.put(name, deserializeArray(jp, ctxt).unwrapped()); break; case START_OBJECT: mapping.put(name, deserializeObject(jp, ctxt).unwrapped()); break; case VALUE_FALSE: mapping.put(name, false); break; case VALUE_TRUE: mapping.put(name, true); break; case VALUE_NULL: mapping.put(name, null); break; case VALUE_NUMBER_FLOAT: if (jp.getNumberType() == JsonParser.NumberType.BIG_DECIMAL) { mapping.put(name, jp.getDecimalValue()); } else { mapping.put(name, jp.getDoubleValue()); } break; case VALUE_NUMBER_INT: // very cumbersome... but has to be done switch (jp.getNumberType()) { case LONG: mapping.put(name, jp.getLongValue()); break; case INT: mapping.put(name, jp.getIntValue()); break; default: mapping.put(name, jp.getBigIntegerValue()); } break; case VALUE_STRING: mapping.put(name, jp.getText()); break; case VALUE_EMBEDDED_OBJECT: { Object ob = jp.getEmbeddedObject(); if (ob instanceof byte[]) { String b64 = ctxt.getBase64Variant().encode((byte[]) ob, false); mapping.put(name, b64); break; } } default: throw ctxt.mappingException(_valueClass); } } return ConfigValueFactory.fromMap(mapping); }
From source file:com.cedarsoft.couchdb.io.CouchSerializerWrapper.java
@Nonnull @Override/*from www. j a v a2 s. com*/ protected JsonParser createJsonParser(@Nonnull JsonFactory jsonFactory, @Nonnull InputStream in) throws IOException { JsonParser parser = super.createJsonParser(jsonFactory, in); return new FilteringJsonParser(parser, new Filter() { @Override public boolean shallFilterOut(@Nonnull JsonParser parser) throws IOException, JsonParseException { @Nullable String currentName = parser.getCurrentName(); return currentName.startsWith("_"); } }); }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.NavigationPropertyDeserializer.java
@Override protected NavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final NavigationProperty property = new NavigationProperty(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { property.setName(jp.nextTextValue()); } else if ("Type".equals(jp.getCurrentName())) { property.setType(jp.nextTextValue()); } else if ("Nullable".equals(jp.getCurrentName())) { property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Partner".equals(jp.getCurrentName())) { property.setPartner(jp.nextTextValue()); } else if ("ContainsTarget".equals(jp.getCurrentName())) { property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("ReferentialConstraint".equals(jp.getCurrentName())) { jp.nextToken();/*from w w w . ja v a 2 s . c om*/ property.getReferentialConstraints() .add(jp.getCodec().readValue(jp, ReferentialConstraint.class)); } else if ("OnDelete".equals(jp.getCurrentName())) { jp.nextToken(); property.setOnDelete(jp.getCodec().readValue(jp, OnDelete.class)); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); property.setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return property; }