Search in sources :

Example 11 with JsonToken

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

the class ActionsJsonDeserializer method processIndexOfJsonToken.

protected IndexOf processIndexOfJsonToken(JsonParser jsonToken) throws IOException {
    IndexOf action = new IndexOf();
    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 12 with JsonToken

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

the class ActionsJsonDeserializer method processAddSecondsJsonToken.

protected AddSeconds processAddSecondsJsonToken(JsonParser jsonToken) throws IOException {
    AddSeconds action = new AddSeconds();
    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.SECONDS:
                jsonToken.nextToken();
                action.setSeconds(jsonToken.getIntValue());
                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 13 with JsonToken

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

the class ActionsJsonDeserializer method processConvertDistanceUnitJsonToken.

protected ConvertDistanceUnit processConvertDistanceUnitJsonToken(JsonParser jsonToken) throws IOException {
    ConvertDistanceUnit action = new ConvertDistanceUnit();
    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.FROM_UNIT:
                jsonToken.nextToken();
                action.setFromUnit(DistanceUnitType.fromValue(jsonToken.getValueAsString()));
                break;
            case ActionsJsonSerializer.TO_UNIT:
                jsonToken.nextToken();
                action.setToUnit(DistanceUnitType.fromValue(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 14 with JsonToken

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

the class ActionsJsonDeserializer method processSubStringAfterJsonToken.

protected SubStringAfter processSubStringAfterJsonToken(JsonParser jsonToken) throws IOException {
    SubStringAfter action = new SubStringAfter();
    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 15 with JsonToken

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

the class ActionsJsonDeserializer method processPadStringLeftJsonToken.

protected PadStringLeft processPadStringLeftJsonToken(JsonParser jsonToken) throws IOException {
    PadStringLeft action = new PadStringLeft();
    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.PAD_CHARACTER:
                jsonToken.nextToken();
                action.setPadCharacter(jsonToken.getValueAsString());
                break;
            case ActionsJsonSerializer.PAD_COUNT:
                jsonToken.nextToken();
                action.setPadCount(jsonToken.getIntValue());
                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)

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