Search in sources :

Example 1 with RegionEnum

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

the class JacksonPageModelParser method parseRegions.

/**
     * @param parser
     * @param layoutId
     * @throws JsonParseException
     * @throws IOException
     */
private List<RegionInstance> parseRegions(JsonParser parser, String segment) throws JsonParseException, IOException {
    JsonToken current = parser.nextToken();
    assertExpectedJsonToken(current, JsonToken.START_ARRAY, parser.getCurrentLocation());
    List<RegionInstance> instances = new ArrayList<RegionInstance>();
    while ((current = parser.nextToken()) != JsonToken.END_ARRAY) {
        assertExpectedJsonToken(current, JsonToken.START_OBJECT, parser.getCurrentLocation());
        // get regionId
        String regionId = getNextTextValue("cid", parser);
        RegionEnum region = RegionEnum.valueOf(regionId);
        // move to field: widgtes
        current = parser.nextToken();
        assertExpectedFiled(parser.getCurrentName(), "widgets", parser.getCurrentLocation());
        RegionInstance instance = new RegionInstance();
        instance.setWidgtes(parseWidgets(parser, region));
        instances.add(instance);
        assertExpectedJsonToken((current = parser.nextToken()), JsonToken.END_OBJECT, parser.getCurrentLocation());
    }
    return instances;
}
Also used : RegionEnum(com.alibaba.json.test.entity.pagemodel.RegionEnum) ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) JsonParserHelper.assertExpectedJsonToken(com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken) RegionInstance(com.alibaba.json.test.entity.pagemodel.RegionInstance)

Aggregations

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