Search in sources :

Example 1 with WidgetInstance

use of com.alibaba.json.test.entity.pagemodel.WidgetInstance in project fastjson by alibaba.

the class JacksonPageModelParser method parseWidgets.

/**
     * @param parser
     * @param layoutId
     * @param regionId
     * @throws JsonParseException
     * @throws IOException
     */
private List<WidgetInstance> parseWidgets(JsonParser parser, RegionEnum region) throws JsonParseException, IOException {
    JsonToken current = parser.nextToken();
    assertExpectedJsonToken(current, JsonToken.START_ARRAY, parser.getCurrentLocation());
    List<WidgetInstance> widgetInThisRegion = new ArrayList<WidgetInstance>();
    while ((current = parser.nextToken()) != JsonToken.END_ARRAY) {
        assertExpectedJsonToken(current, JsonToken.START_OBJECT, parser.getCurrentLocation());
        // get
        String instanceId = getNextTextValue("sid", parser);
        // instanceId
        // get
        String widgetId = getNextTextValue("cid", parser);
        // widgetId
        WidgetInstance widgetInstance = new WidgetInstance();
        widgetInstance.setCid(widgetId);
        widgetInstance.setSid(Long.valueOf(instanceId));
        widgetInThisRegion.add(widgetInstance);
        assertExpectedJsonToken((current = parser.nextToken()), JsonToken.END_OBJECT, parser.getCurrentLocation());
    }
    return widgetInThisRegion;
}
Also used : ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) JsonParserHelper.assertExpectedJsonToken(com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken) WidgetInstance(com.alibaba.json.test.entity.pagemodel.WidgetInstance)

Aggregations

WidgetInstance (com.alibaba.json.test.entity.pagemodel.WidgetInstance)1 JsonParserHelper.assertExpectedJsonToken (com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken)1 JsonToken (com.fasterxml.jackson.core.JsonToken)1 ArrayList (java.util.ArrayList)1