Example usage for com.fasterxml.jackson.core JsonToken FIELD_NAME

List of usage examples for com.fasterxml.jackson.core JsonToken FIELD_NAME

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonToken FIELD_NAME.

Prototype

JsonToken FIELD_NAME

To view the source code for com.fasterxml.jackson.core JsonToken FIELD_NAME.

Click Source Link

Document

FIELD_NAME is returned when a String token is encountered as a field name (same lexical value, different function)

Usage

From source file:com.taveloper.http.test.pojo.parse.ActivityFeedParse.java

public ActivityFeed readJson(JsonParser in) throws JsonParseException, IOException {
    //        System.out.println("ActivityFeedParse.readJson");
    JsonToken curToken = in.nextToken();
    ActivityFeed object = new ActivityFeed();
    while (curToken == JsonToken.FIELD_NAME) {
        String curName = in.getText();
        JsonToken nextToken = in.nextToken();
        if ("items".equals(curName)) {
            ArrayList<Activity> arrayList = new ArrayList<Activity>();
            ActivityParse activityParse = new ActivityParse();
            switch (nextToken) {
            case START_ARRAY:
                while (in.nextToken() != JsonToken.END_ARRAY) {
                    arrayList.add(activityParse.readJson(in));
                }//ww w.j a v  a  2s .  c  o  m
                break;
            case START_OBJECT:
                arrayList.add(activityParse.readJson(in));
                break;
            default:
                throw new IllegalArgumentException(
                        "unexpected JSON node type: " + nextToken + in.getCurrentName());
            }
            object.setActivities(arrayList);
        }
        curToken = in.nextToken();
    }
    return object;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.EdmxDeserializer.java

@Override
public Edmx deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final Edmx edmx = new Edmx();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Version".equals(jp.getCurrentName())) {
                edmx.setVersion(jp.nextTextValue());
            } else if ("DataServices".equals(jp.getCurrentName())) {
                jp.nextToken();/*www  . j a  va  2  s .co  m*/
                edmx.setDataServices(jp.getCodec().readValue(jp, DataServices.class));
            }
        }
    }

    return edmx;
}

From source file:com.netflix.discovery.converters.jackson.serializer.PortWrapperXmlDeserializer.java

@Override
public InstanceInfo.PortWrapper deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    boolean enabled = false;
    int port = 0;
    while (jp.nextToken() == JsonToken.FIELD_NAME) {
        String fieldName = jp.getCurrentName();
        jp.nextToken(); // to point to value
        if ("enabled".equals(fieldName)) {
            enabled = Boolean.valueOf(jp.getValueAsString());
        } else if (fieldName == null || "".equals(fieldName)) {
            String value = jp.getValueAsString();
            port = value == null ? 0 : Integer.parseInt(value);
        } else {//  ww w.  j a  v a2s . c  o m
            throw new JsonMappingException("Unexpected field " + fieldName, jp.getCurrentLocation());
        }
    }
    return new InstanceInfo.PortWrapper(enabled, port);
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.EntityKeyDeserializer.java

@Override
public EntityKey deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final EntityKey entityKey = new EntityKey();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();

        if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) {
            jp.nextToken();/*from w  w w . j  a  v a2  s . c  o  m*/
            entityKey.getPropertyRefs().add(jp.getCodec().readValue(jp, PropertyRef.class));
        }
    }

    return entityKey;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.AssociationDeserializer.java

@Override
public Association deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final Association association = new Association();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                association.setName(jp.nextTextValue());
            } else if ("ReferentialConstraint".equals(jp.getCurrentName())) {
                jp.nextToken();/*w w w  . ja va 2 s  .  co  m*/
                association.setReferentialConstraint(jp.getCodec().readValue(jp, ReferentialConstraint.class));
            } else if ("End".equals(jp.getCurrentName())) {
                jp.nextToken();
                association.getEnds().add(jp.getCodec().readValue(jp, AssociationEnd.class));
            }
        }
    }

    return association;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.DataServicesDeserializer.java

@Override
public DataServices deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final DataServices dataServices = new DataServices();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("DataServiceVersion".equals(jp.getCurrentName())) {
                dataServices.setDataServiceVersion(jp.nextTextValue());
            } else if ("MaxDataServiceVersion".equals(jp.getCurrentName())) {
                dataServices.setMaxDataServiceVersion(jp.nextTextValue());
            } else if ("Schema".equals(jp.getCurrentName())) {
                jp.nextToken();/*from  ww w . j a va2 s  .c o  m*/
                dataServices.getSchemas().add(jp.getCodec().readValue(jp, Schema.class));
            }
        }
    }

    return dataServices;
}

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();//from   w w  w .j  a v  a 2s. co 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.AssociationSetDeserializer.java

@Override
public AssociationSet deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final AssociationSet associationSet = new AssociationSet();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                associationSet.setName(jp.nextTextValue());
            } else if ("Association".equals(jp.getCurrentName())) {
                associationSet.setAssociation(jp.nextTextValue());
            } else if ("End".equals(jp.getCurrentName())) {
                jp.nextToken();/*from ww  w. j a va  2  s.c  o m*/
                associationSet.getEnds().add(jp.getCodec().readValue(jp, AssociationSetEnd.class));
            }
        }
    }

    return associationSet;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.TypeAnnotationDeserializer.java

@Override
public TypeAnnotation deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final TypeAnnotation typeAnnot = new TypeAnnotation();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Term".equals(jp.getCurrentName())) {
                typeAnnot.setTerm(jp.nextTextValue());
            } else if ("Qualifier".equals(jp.getCurrentName())) {
                typeAnnot.setQualifier(jp.nextTextValue());
            } else if ("Documentation".equals(jp.getCurrentName())) {
                jp.nextToken();/*from  w  w  w .j  a va2  s .c om*/
                typeAnnot.setDocumentation(jp.getCodec().readValue(jp, Documentation.class));
            } else if ("PropertyValue".equals(jp.getCurrentName())) {
                jp.nextToken();
                typeAnnot.getPropertyValues().add(jp.getCodec().readValue(jp, PropertyValue.class));
            }
        }
    }

    return typeAnnot;
}

From source file:com.reprezen.swagedit.model.NodeDeserializer.java

@Override
public AbstractNode deserialize(JsonParser p, DeserializationContext context)
        throws IOException, JsonProcessingException {

    JsonLocation startLocation = p.getTokenLocation();
    if (p.getCurrentToken() == JsonToken.FIELD_NAME) {
        p.nextToken();/*from w  ww. j  a va  2  s  .  c  om*/
    }

    switch (p.getCurrentToken()) {
    case START_OBJECT:
        return deserializeObjectNode(p, context, startLocation);
    case START_ARRAY:
        return deserializeArrayNode(p, context, startLocation);
    default:
        return deserializeValueNode(p, context, startLocation);
    }
}