Search in sources :

Example 16 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.

the class ActionsJsonDeserializer method processCustomActionJsonToken.

protected CustomAction processCustomActionJsonToken(JsonParser jsonToken) throws IOException {
    CustomAction action = new CustomAction();
    if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
        return action;
    }
    JsonToken nextToken = null;
    do {
        if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
            jsonToken.nextToken();
        }
        switch(jsonToken.getCurrentName()) {
            case ActionsJsonSerializer.CLASS_NAME:
                jsonToken.nextToken();
                action.setClassName(jsonToken.getValueAsString());
                break;
            case ActionsJsonSerializer.METHOD_NAME:
                jsonToken.nextToken();
                action.setMethodName(jsonToken.getValueAsString());
                break;
            default:
                break;
        }
        nextToken = jsonToken.nextToken();
    } while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
    return action;
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 17 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.

the class ActionsJsonDeserializer method processSubStringBeforeJsonToken.

protected SubStringBefore processSubStringBeforeJsonToken(JsonParser jsonToken) throws IOException {
    SubStringBefore action = new SubStringBefore();
    if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
        return action;
    }
    JsonToken nextToken = null;
    do {
        if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
            jsonToken.nextToken();
        }
        switch(jsonToken.getCurrentName()) {
            case ActionsJsonSerializer.START_INDEX:
                jsonToken.nextToken();
                action.setStartIndex(jsonToken.getIntValue());
                break;
            case ActionsJsonSerializer.END_INDEX:
                jsonToken.nextToken();
                action.setEndIndex(jsonToken.getIntValue());
                break;
            case ActionsJsonSerializer.MATCH:
                jsonToken.nextToken();
                action.setMatch(jsonToken.getValueAsString());
                break;
            default:
                break;
        }
        nextToken = jsonToken.nextToken();
    } while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
    return action;
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 18 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.

the class ActionsJsonDeserializer method processPrependJsonToken.

protected Prepend processPrependJsonToken(JsonParser jsonToken) throws IOException {
    Prepend action = new Prepend();
    if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
        return action;
    }
    JsonToken nextToken = null;
    do {
        if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
            jsonToken.nextToken();
        }
        switch(jsonToken.getCurrentName()) {
            case ActionsJsonSerializer.STRING:
                jsonToken.nextToken();
                action.setString(jsonToken.getValueAsString());
                break;
            default:
                break;
        }
        nextToken = jsonToken.nextToken();
    } while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
    return action;
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 19 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project kie-wb-common by kiegroup.

the class AbstractParser method nextToken.

@Override
public JsonToken nextToken() throws IOException, JsonParseException {
    JsonToken token = next();
    tokenCount++;
    return token;
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 20 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project incubator-servicecomb-java-chassis by apache.

the class AbstractDeserializer method deserialize.

@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    Object result = createResult();
    for (String fieldName = p.nextFieldName(); fieldName != null; fieldName = p.nextFieldName()) {
        // p实际是ProtobufParser,其内部是可以直接取到proto field的,理论上可以根据id来索引
        // 可是field默认没暴露出来,所以,直接用name索引了
        ReaderHelpData helpData = readerHelpDataMap.get(fieldName);
        if (helpData == null) {
            continue;
        }
        JsonToken t = p.nextToken();
        // Note: must handle null explicitly here; value deserializers won't
        Object value = null;
        if (t == JsonToken.VALUE_NULL) {
            value = helpData.getDeser().getNullValue(ctxt);
        } else {
            value = helpData.getDeser().deserialize(p, ctxt);
        }
        result = updateResult(result, value, helpData);
    }
    return result;
}
Also used : ReaderHelpData(org.apache.servicecomb.codec.protobuf.codec.AbstractFieldCodec.ReaderHelpData) JsonToken(com.fasterxml.jackson.core.JsonToken)

Aggregations

JsonToken (com.fasterxml.jackson.core.JsonToken)251 IOException (java.io.IOException)65 JsonParser (com.fasterxml.jackson.core.JsonParser)44 ArrayList (java.util.ArrayList)27 HashMap (java.util.HashMap)25 JsonFactory (com.fasterxml.jackson.core.JsonFactory)18 JsonParseException (com.fasterxml.jackson.core.JsonParseException)15 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)9 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)6 SqlNullable (com.facebook.presto.spi.function.SqlNullable)6 SqlType (com.facebook.presto.spi.function.SqlType)6 JsonUtil.createJsonParser (com.facebook.presto.util.JsonUtil.createJsonParser)6 JsonParserHelper.assertExpectedJsonToken (com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken)5 InputStream (java.io.InputStream)5 LinkedHashMap (java.util.LinkedHashMap)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)4 ByteString (com.google.protobuf.ByteString)4 HashSet (java.util.HashSet)4 MappingJsonFactory (com.fasterxml.jackson.databind.MappingJsonFactory)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3