Search in sources :

Example 1 with SegmentInstance

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

the class JacksonPageModelParser method parseSegments.

/**
     * @param parser
     * @throws JsonParseException
     * @throws IOException
     */
private List<SegmentInstance> parseSegments(JsonParser parser) throws JsonParseException, IOException {
    JsonToken current = parser.nextToken();
    assertExpectedJsonToken(current, JsonToken.START_ARRAY, parser.getCurrentLocation());
    List<SegmentInstance> instances = new ArrayList<SegmentInstance>();
    while ((current = parser.nextToken()) != JsonToken.END_ARRAY) {
        assertExpectedJsonToken(current, JsonToken.START_OBJECT, parser.getCurrentLocation());
        // get pageId
        String segmentId = getNextTextValue("cid", parser);
        // move to field: layouts
        current = parser.nextToken();
        assertExpectedFiled(parser.getCurrentName(), "layouts", parser.getCurrentLocation());
        SegmentInstance instance = new SegmentInstance();
        instance.setLayouts(parseLayouts(parser, segmentId));
        instances.add(instance);
        assertExpectedJsonToken((current = parser.nextToken()), JsonToken.END_OBJECT, parser.getCurrentLocation());
    }
    return instances;
}
Also used : SegmentInstance(com.alibaba.json.test.entity.pagemodel.SegmentInstance) ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) JsonParserHelper.assertExpectedJsonToken(com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken)

Aggregations

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