Search in sources :

Example 71 with JsonToken

use of com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.

the class ActionsJsonDeserializer method processConvertMassUnitJsonToken.

protected ConvertMassUnit processConvertMassUnitJsonToken(JsonParser jsonToken) throws IOException {
    ConvertMassUnit action = new ConvertMassUnit();
    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(MassUnitType.fromValue(jsonToken.getValueAsString()));
                break;
            case ActionsJsonSerializer.TO_UNIT:
                jsonToken.nextToken();
                action.setToUnit(MassUnitType.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 72 with JsonToken

use of com.fasterxml.jackson.core.JsonToken in project Payara by payara.

the class ProgressStatusEventJsonProprietaryReader method readProgressStatusEvent.

public static ProgressStatusEvent readProgressStatusEvent(JsonParser jp) throws IOException {
    String id = null;
    JsonToken token = null;
    ProgressStatusEvent result = null;
    while ((token = jp.nextToken()) != JsonToken.END_OBJECT) {
        if (token == JsonToken.START_OBJECT) {
            String nm = jp.getCurrentName();
            if ("set".equals(nm)) {
                result = new ProgressStatusEventSet(id);
                readToPSEventSet((ProgressStatusEventSet) result, jp);
            } else if ("progres".equals(nm)) {
                result = new ProgressStatusEventProgress(id);
                readToPSEventProgress((ProgressStatusEventProgress) result, jp);
            } else if ("complete".equals(nm)) {
                result = new ProgressStatusEventComplete(id);
                readToPSEventComplete((ProgressStatusEventComplete) result, jp);
            } else if ("create-child".equals(nm)) {
                result = new ProgressStatusEventCreateChild(id);
                readToPSEventCreateChild((ProgressStatusEventCreateChild) result, jp);
            }
        } else {
            String fieldname = jp.getCurrentName();
            if ("id".equals(fieldname)) {
                // move to value
                jp.nextToken();
                id = jp.getText();
            }
        }
    }
    return result;
}
Also used : ProgressStatusEventComplete(org.glassfish.api.admin.progress.ProgressStatusEventComplete) ProgressStatusEventCreateChild(org.glassfish.api.admin.progress.ProgressStatusEventCreateChild) ProgressStatusEvent(org.glassfish.api.admin.progress.ProgressStatusEvent) JsonToken(com.fasterxml.jackson.core.JsonToken) ProgressStatusEventProgress(org.glassfish.api.admin.progress.ProgressStatusEventProgress) ProgressStatusEventSet(org.glassfish.api.admin.progress.ProgressStatusEventSet)

Aggregations

JsonToken (com.fasterxml.jackson.core.JsonToken)72 JsonParser (com.fasterxml.jackson.core.JsonParser)14 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)8 SqlNullable (com.facebook.presto.spi.function.SqlNullable)7 SqlType (com.facebook.presto.spi.function.SqlType)7 JsonUtil.createJsonParser (com.facebook.presto.util.JsonUtil.createJsonParser)7 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)6 JsonParserHelper.assertExpectedJsonToken (com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken)5 JsonParseException (com.fasterxml.jackson.core.JsonParseException)3 LiteralParameters (com.facebook.presto.spi.function.LiteralParameters)2 RpcHint (com.navercorp.pinpoint.web.filter.RpcHint)2 InputStream (java.io.InputStream)2 ValueSerializationException (org.qi4j.api.value.ValueSerializationException)2 Company (com.alibaba.json.test.entity.Company)1 Department (com.alibaba.json.test.entity.Department)1 Employee (com.alibaba.json.test.entity.Employee)1 Group (com.alibaba.json.test.entity.Group)1 LayoutInstance (com.alibaba.json.test.entity.pagemodel.LayoutInstance)1 PageInstance (com.alibaba.json.test.entity.pagemodel.PageInstance)1