Search in sources :

Example 1 with LayoutInstance

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

the class JacksonPageModelParser method parseLayouts.

/**
     * @param parser
     * @param segmentId
     * @throws JsonParseException
     * @throws IOException
     */
private List<LayoutInstance> parseLayouts(JsonParser parser, String segment) throws JsonParseException, IOException {
    JsonToken current = parser.nextToken();
    assertExpectedJsonToken(current, JsonToken.START_ARRAY, parser.getCurrentLocation());
    List<LayoutInstance> layoutInThisSegment = new ArrayList<LayoutInstance>();
    while ((current = parser.nextToken()) != JsonToken.END_ARRAY) {
        assertExpectedJsonToken(current, JsonToken.START_OBJECT, parser.getCurrentLocation());
        // get
        String instanceId = getNextTextValue("sid", parser);
        // instanceId
        // get
        String layoutId = getNextTextValue("cid", parser);
        // layoutId
        LayoutInstance layoutInstance = new LayoutInstance();
        layoutInstance.setCid(layoutId);
        layoutInstance.setSid(Long.valueOf(instanceId));
        layoutInThisSegment.add(layoutInstance);
        // move to field: regions
        current = parser.nextToken();
        assertExpectedFiled(parser.getCurrentName(), "regions", parser.getCurrentLocation());
        layoutInstance.setRegions(parseRegions(parser, segment));
        assertExpectedJsonToken((current = parser.nextToken()), JsonToken.END_OBJECT, parser.getCurrentLocation());
    }
    return layoutInThisSegment;
}
Also used : ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) JsonParserHelper.assertExpectedJsonToken(com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken) LayoutInstance(com.alibaba.json.test.entity.pagemodel.LayoutInstance)

Aggregations

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