当前位置: 首页>>代码示例>>Java>>正文


Java JsonToken.END_OBJECT属性代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.JsonToken.END_OBJECT属性的典型用法代码示例。如果您正苦于以下问题:Java JsonToken.END_OBJECT属性的具体用法?Java JsonToken.END_OBJECT怎么用?Java JsonToken.END_OBJECT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.fasterxml.jackson.core.JsonToken的用法示例。


在下文中一共展示了JsonToken.END_OBJECT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readRecord

Map<String, Object> readRecord(JsonParser jp) throws IOException {

        Map<String, Object> record = new HashMap<>();
        String fielName =  "";
        Object value;
        JsonToken token;

        while((token = jp.nextToken()) != JsonToken.END_OBJECT) {
            if (token == JsonToken.FIELD_NAME) {
                fielName = jp.getCurrentName();
            } else if (token == JsonToken.VALUE_STRING) {
                value = jp.getValueAsString();
                record.put(fielName, value);
            } else if (token == JsonToken.VALUE_NUMBER_INT) {
                value = jp.getValueAsLong();
                record.put(fielName, value);
            }
        }

        //System.out.println(record.toString());
        return record;
    }
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:22,代码来源:JsonDatabaseReader.java

示例2: parse

@Override
public SimpleGenericModel<T> parse(JsonParser jsonParser) throws IOException {
  SimpleGenericModel<T> instance = new SimpleGenericModel<T>();
  if (jsonParser.getCurrentToken() == null) {
    jsonParser.nextToken();
  }
  if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jsonParser.skipChildren();
    return null;
  }
  while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
    String fieldName = jsonParser.getCurrentName();
    jsonParser.nextToken();
    parseField(instance, fieldName, jsonParser);
    jsonParser.skipChildren();
  }
  return instance;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SimpleGenericModel$$JsonObjectMapper.java

示例3: parse

@Override
public ParentModel parse(JsonParser jsonParser) throws IOException {
    ParentModel instance = new ParentModel();
    if (jsonParser.getCurrentToken() == null) {
        jsonParser.nextToken();
    }
    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jsonParser.skipChildren();
        return null;
    }
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.getCurrentName();
        jsonParser.nextToken();
        parseField(instance, fieldName, jsonParser);
        jsonParser.skipChildren();
    }
    return instance;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ParentModel$$JsonObjectMapper.java

示例4: jsonExtractSubnetMask

/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
	String subnet_mask = "";
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals(""))
			continue;

		if (n == "subnet-mask") {
			subnet_mask = jp.getText();
			break;
		}
	}

	return subnet_mask;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:FirewallSubnetMaskResource.java

示例5: deserialize

@Override
public LoadFlowResult deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
    Boolean isOK = null;
    Map<String, String> metrics = null;
    String log = null;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "version":
                parser.nextToken(); // skip
                break;

            case "isOK":
                parser.nextToken();
                isOK = parser.readValueAs(Boolean.class);
                break;

            case "metrics":
                parser.nextToken();
                metrics = parser.readValueAs(HashMap.class);
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new LoadFlowResultImpl(isOK, metrics, log);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:29,代码来源:LoadFlowResultDeserializer.java

示例6: parseMap

/**
 * Parse a map of objects from a JsonParser.
 *
 * @param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token.
 */
public Map<String, T> parseMap(JsonParser jsonParser) throws IOException {
    HashMap<String, T> map = new HashMap<String, T>();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String key = jsonParser.getText();
        jsonParser.nextToken();
        if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
            map.put(key, null);
        } else{
            map.put(key, parse(jsonParser));
        }
    }
    return map;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JsonMapper.java

示例7: parseDepartment

private Department parseDepartment() throws Exception {
    accept(JsonToken.START_OBJECT);

    Department company = new Department();

    for (;;) {
        JsonToken tok = parser.getCurrentToken();

        if (tok == JsonToken.END_OBJECT) {
            break;
        }

        if (tok == JsonToken.FIELD_NAME) {
            String name = parser.getCurrentName();
            tok = parser.nextToken();

            if ("name" == name) {
                company.setName(acceptString(tok));
            } else if ("description" == name) {
                company.setDescription(acceptString(tok));
            } else if ("id" == name) {
                company.setId(acceptLong(tok));
            } else if ("children" == name) {
                parseDepartment(company.getChildren());
            } else if ("members" == name) {
                parseEmployee(company.getMembers());
            } else {
                throw new RuntimeException("not match property : " + name);
            }
        }
    }

    accept(JsonToken.END_OBJECT);

    return company;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:JacksonGroupParser.java

示例8: parsePersons

public void parsePersons(String filename) {
    try {
        JsonFactory jsonfactory = new JsonFactory();
        File source = new File(filename);
        JsonParser parser = jsonfactory.createParser(source);
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String token = parser.getCurrentName();
            if ("persons".equals(token)) {
                out.println("Persons found");
                JsonToken jsonToken = parser.nextToken();
                jsonToken = parser.nextToken();
                token = parser.getCurrentName();
                out.println("Next token is " + token);
                if ("groupname".equals(token)) {
                    parser.nextToken();
                    String groupname = parser.getText();
                    out.println("Group : " + groupname);
                    parser.nextToken();
                    token = parser.getCurrentName();
                    if ("person".equals(token)) {
                        out.println("Found person");
                        parsePerson(parser);
                    }
                }
            }
        }
        parser.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:31,代码来源:JSONExamples.java

示例9: parsePerson

public static void parsePerson() {
    try {
        JsonFactory jsonfactory = new JsonFactory();
        JsonParser parser = jsonfactory.createParser(new File("Person.json"));
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String token = parser.getCurrentName();

            if ("firstname".equals(token)) {
                parser.nextToken();
                String fname = parser.getText();
                out.println("firstname : " + fname);
            }
            if ("lastname".equals(token)) {
                parser.nextToken();
                String lname = parser.getText();
                out.println("lastname : " + lname);
            }
            if ("phone".equals(token)) {
                parser.nextToken();
                long phone = parser.getLongValue();
                out.println("phone : " + phone);
            }
            if ("address".equals(token)) {
                out.println("address :");
                parser.nextToken();
                while (parser.nextToken() != JsonToken.END_ARRAY) {
                    out.println(parser.getText());
                }
            }
        }
        parser.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Made-Easy,代码行数:35,代码来源:JSONExamples.java

示例10: skipChildren

@Override
public JsonParser skipChildren() throws IOException, JsonParseException {
    IonType currentType = reader.getType();
    if (IonType.isContainer(currentType)) {
        shouldSkipContainer = true;
        currentToken = currentType == IonType.STRUCT
                       ? JsonToken.END_OBJECT
                       : JsonToken.END_ARRAY;
    }
    return this;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:11,代码来源:IonParser.java

示例11: readCollectionData

@SuppressWarnings("unchecked")
private void readCollectionData(NitriteCollection collection) throws IOException {
    // move to [
    parser.nextToken();

    // loop till token equal to "]"
    while (parser.nextToken() != JsonToken.END_ARRAY) {
        // loop until end of collection object
        Long id = null;
        Map<String, Object> objectMap = null;
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String fieldName = parser.getCurrentName();

            if (TAG_KEY.equals(fieldName)) {
                parser.nextToken();
                id = parser.readValueAs(Long.class);
            }

            if (TAG_VALUE.equals(fieldName)) {
                parser.nextToken();
                objectMap = (Map<String, Object>) parser.readValueAs(Map.class);
                objectMap.put(DOC_ID, id);
            }

            if (objectMap != null) {
                Document document = new Document(objectMap);

                if (collection != null) {
                    collection.insert(document);
                }
            }
        }
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:34,代码来源:NitriteJsonImporter.java

示例12: parseJson

static List<TimeSeries> parseJson(JsonParser parser, boolean single) {
    Objects.requireNonNull(parser);
    List<TimeSeries> timeSeriesList = new ArrayList<>();
    try {
        TimeSeriesMetadata metadata = null;
        JsonToken token;
        while ((token = parser.nextToken()) != null) {
            if (token == JsonToken.FIELD_NAME) {
                String fieldName = parser.getCurrentName();
                switch (fieldName) {
                    case "metadata":
                        metadata = TimeSeriesMetadata.parseJson(parser);
                        break;
                    case "chunks":
                        if (metadata == null) {
                            throw new AssertionError("metadata is null");
                        }
                        parseChunks(parser, metadata, timeSeriesList);
                        metadata = null;
                        break;
                    default:
                        break;
                }
            } else if (token == JsonToken.END_OBJECT && single) {
                break;
            }
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return timeSeriesList;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:32,代码来源:TimeSeries.java

示例13: deserialize

@Override
public NodeDependency deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    String name = null;
    NodeInfo nodeInfo = null;
    JsonToken token;
    while ((token = jsonParser.nextToken()) != null) {
        if (token == JsonToken.END_OBJECT) {
            break;
        } else if (token == JsonToken.FIELD_NAME) {
            switch (jsonParser.getCurrentName()) {
                case "name":
                    jsonParser.nextToken();
                    name = jsonParser.getValueAsString();
                    break;

                case "nodeInfo":
                    nodeInfo = new NodeInfoJsonDeserializer().deserialize(jsonParser, deserializationContext);
                    break;

                default:
                    throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());

            }
        }
    }
    if (name == null || nodeInfo == null) {
        throw new IllegalStateException("Inconsistent node dependency json");
    }
    return new NodeDependency(name, nodeInfo);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:30,代码来源:NodeDependencyDeserializer.java

示例14: jsonToMember

protected LBMember jsonToMember(String json) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBMember member = new LBMember();
    
    try {
        jp = f.createParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        if (n.equals("id")) {
            member.id = jp.getText();
            continue;
        } else
        if (n.equals("address")) {
            member.address = IPv4.toIPv4Address(jp.getText());
            continue;
        } else
        if (n.equals("port")) {
            member.port = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("connection_limit")) {
            member.connectionLimit = Integer.parseInt(jp.getText());
            continue;
        } else
        if (n.equals("admin_state")) {
            member.adminState = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("status")) {
            member.status = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("pool_id")) {
            member.poolId = jp.getText();
            continue;
        } 
        
        log.warn("Unrecognized field {} in " +
                "parsing Members", 
                jp.getText());
    }
    jp.close();

    return member;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:62,代码来源:MembersResource.java

示例15: parseEmployee

private Employee parseEmployee() throws Exception {
    accept(JsonToken.START_OBJECT);

    Employee emp = new Employee();

    for (;;) {
        JsonToken tok = parser.getCurrentToken();

        if (tok == JsonToken.END_OBJECT) {
            break;
        }

        if (tok == JsonToken.FIELD_NAME) {
            String name = parser.getCurrentName();
            tok = parser.nextToken();

            if ("name" == name) {
                emp.setName(acceptString(tok));
            } else if ("description" == name) {
                emp.setDescription(acceptString(tok));
            } else if ("number" == name) {
                emp.setNumber(acceptString(tok));
            } else if ("id" == name) {
                emp.setId(acceptLong(tok));
            } else if ("age" == name) {
                emp.setAge(acceptInteger(tok));
            } else if ("salary" == name) {
                emp.setSalary(acceptBigDecimal(tok));
            } else if ("birthdate" == name) {
                emp.setBirthdate(new Date(acceptLong(tok)));
            } else if ("badboy" == name) {
                emp.setBadboy(acceptBoolean(tok));
            } else {
                throw new RuntimeException("not match property : " + name);
            }
        }
    }

    accept(JsonToken.END_OBJECT);

    return emp;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:JacksonGroupParser.java


注:本文中的com.fasterxml.jackson.core.JsonToken.END_OBJECT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。