本文整理汇总了Java中com.fasterxml.jackson.core.JsonToken.END_ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java JsonToken.END_ARRAY属性的具体用法?Java JsonToken.END_ARRAY怎么用?Java JsonToken.END_ARRAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.fasterxml.jackson.core.JsonToken
的用法示例。
在下文中一共展示了JsonToken.END_ARRAY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
String regionId = getNextTextValue("cid", parser); // get regionId
RegionEnum region = RegionEnum.valueOf(regionId);
current = parser.nextToken(); // move to field: widgtes
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;
}
示例2: parseField
@Override
public void parseField(NonPrivateFieldsFieldDetectionPolicyModel instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("annotated_string".equals(fieldName)) {
instance.annotatedString = jsonParser.getValueAsString(null);
} else if ("intToIgnoreForSerialization".equals(fieldName)){
instance.intToIgnoreForSerialization = jsonParser.getValueAsInt();
} else if ("nonAnnotatedList".equals(fieldName)){
if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
ArrayList<String> collection1 = new ArrayList<String>();
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
String value1;
value1 = jsonParser.getValueAsString(null);
collection1.add(value1);
}
instance.nonAnnotatedList = collection1;
} else {
instance.nonAnnotatedList = null;
}
} else if ("nonAnnotatedString".equals(fieldName)){
instance.nonAnnotatedString = jsonParser.getValueAsString(null);
} else if ("staticIntToInclude".equals(fieldName)){
instance.staticIntToInclude = jsonParser.getValueAsInt();
} else if ("transientIntToInclude".equals(fieldName)){
instance.transientIntToInclude = jsonParser.getValueAsInt();
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:NonPrivateFieldsFieldDetectionPolicyModel$$JsonObjectMapper.java
示例3: deserialize
@Override
public List<IBaseSegmentDTO> deserialize(InputStream stream) throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
List<IBaseSegmentDTO> segments = new ArrayList<IBaseSegmentDTO>();
JsonToken token = jp.nextToken();
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
segments.add(processSegment(jp, adapter));
}
}
log.info("parsed: " + segments.size() + " segments");
return segments;
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例4: readTable
private void readTable(JsonParser jp) throws IOException {
JsonToken token;
String tableName = "";
int recordCount = 0;
while((token = jp.nextToken()) != JsonToken.END_OBJECT) {
if (token == JsonToken.FIELD_NAME) {
if ("name".equals(jp.getCurrentName())) {
tableName = jp.nextTextValue();
} else if ("records".equals(jp.getCurrentName())){
// Ciclo la lista dei records
while((token = jp.nextToken()) != JsonToken.END_ARRAY) {
readRecord(jp);
recordCount++;
}
}
}
}
System.out.println("\tTable: " + tableName + " records:" + recordCount);
numeriche.put(tableName, recordCount);
}
示例5: deserialize
@Override
public List<T> deserialize(InputStream stream) throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
List<T> segments = new ArrayList<T>();
JsonToken token = jp.nextToken();
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
segments.add(processSegment(jp, adapter));
}
}
log.info("parsed: " + segments.size() + " segments");
return segments;
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例6: _deserializeFromArray
protected String _deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws IOException
{
JsonToken t;
if (ctxt.hasSomeOfFeatures(FEATURES_ACCEPT_ARRAYS)) {
t = p.nextToken();
if (t == JsonToken.END_ARRAY) {
if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)) {
return getNullValue(ctxt);
}
}
if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) {
final String parsed = _parseString(p, ctxt);
if (p.nextToken() != JsonToken.END_ARRAY) {
handleMissingEndArrayForSingle(p, ctxt);
}
return parsed;
}
} else {
t = p.getCurrentToken();
}
return (String) ctxt.handleUnexpectedToken(_valueClass, t, p, null);
}
示例7: readCollection
private void readCollection() throws IOException {
NitriteCollection collection = null;
// move to [
parser.nextToken();
// loop till token equal to "]"
while (parser.nextToken() != JsonToken.END_ARRAY) {
// loop until end of collection object
while (parser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = parser.getCurrentName();
if (TAG_NAME.equals(fieldName)) {
// move to next token
parser.nextToken();
String collectionName = parser.getText();
collection = db.getCollection(collectionName);
}
if (TAG_INDICES.equals(fieldName)) {
readIndices(collection);
}
if (TAG_DATA.equals(fieldName)) {
readCollectionData(collection);
}
}
}
}
示例8: deserialize
@Override
public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException {
switch(parser.getCurrentToken()) {
case START_ARRAY:
if(parser.nextToken() == JsonToken.END_ARRAY) {
return null;
}
int year = parser.getIntValue();
parser.nextToken();
int month = parser.getIntValue();
parser.nextToken();
int day = parser.getIntValue();
if(parser.nextToken() != JsonToken.END_ARRAY) {
throw context.wrongTokenException(parser, JsonToken.END_ARRAY, "Expected array to end.");
}
return LocalDate.of(year, month, day);
case VALUE_STRING:
String string = parser.getText().trim();
if(string.length() == 0) {
return null;
}
return LocalDate.parse(string, ISO_DATE_OPTIONAL_TIME);
}
throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
}
示例9: doMerge
@Override
public void doMerge(JsonParser parser, int currentDepth, Message.Builder messageBuilder)
throws IOException {
JsonToken token = parser.currentToken();
if (token != JsonToken.START_ARRAY) {
throw new InvalidProtocolBufferException("Expect an array but found: " + parser.getText());
}
ListValue.Builder builder = (ListValue.Builder) messageBuilder;
while (parser.nextValue() != JsonToken.END_ARRAY) {
Value.Builder valueBuilder = builder.addValuesBuilder();
ValueMarshaller.INSTANCE.mergeValue(parser, currentDepth + 1, valueBuilder);
}
}
示例10: parseField
@Override
public void parseField(NonPrivateFieldsAndAccessorsFieldDetectionPolicyModel instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("annotated_string".equals(fieldName)) {
instance.annotatedString = jsonParser.getValueAsString(null);
} else if ("intToIgnoreForSerialization".equals(fieldName)){
instance.intToIgnoreForSerialization = jsonParser.getValueAsInt();
} else if ("nonAnnotatedList".equals(fieldName)){
if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
ArrayList<String> collection1 = new ArrayList<String>();
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
String value1;
value1 = jsonParser.getValueAsString(null);
collection1.add(value1);
}
instance.nonAnnotatedList = collection1;
} else {
instance.nonAnnotatedList = null;
}
} else if ("nonAnnotatedPrivateInt".equals(fieldName)){
instance.setNonAnnotatedPrivateInt(jsonParser.getValueAsInt());
} else if ("nonAnnotatedString".equals(fieldName)){
instance.nonAnnotatedString = jsonParser.getValueAsString(null);
} else if ("privateStaticIntToInclude".equals(fieldName)){
instance.setPrivateStaticIntToInclude(jsonParser.getValueAsInt());
} else if ("privateTransientIntToInclude".equals(fieldName)){
instance.setPrivateTransientIntToInclude(jsonParser.getValueAsInt());
} else if ("staticIntToInclude".equals(fieldName)){
instance.staticIntToInclude = jsonParser.getValueAsInt();
} else if ("transientIntToInclude".equals(fieldName)){
instance.transientIntToInclude = jsonParser.getValueAsInt();
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:NonPrivateFieldsAndAccessorsFieldDetectionPolicyModel$$JsonObjectMapper.java
示例11: deserialize
@Override
public void deserialize(InputStream stream, BlockingQueue<T> outputQueue)
throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
JsonToken token = jp.nextToken();
long count = 0;
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
enqueue(outputQueue, processSegment(jp, adapter));
count++;
}
}
log.info("parsed and enqueued: " + count + " segments");
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例12: 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,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:35,代码来源:JSONExamples.java
示例13: parsePerson
public void parsePerson(JsonParser parser) throws IOException {
while (parser.nextToken() != JsonToken.END_ARRAY) {
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());
}
}
}
}
示例14: doNextToken
private JsonToken doNextToken() {
for (;;) {
switch (state) {
case BEFORE_VALUE:
IonType currentType = reader.next();
if (currentType == null) {
boolean topLevel = reader.getDepth() == 0;
if (topLevel) {
state = State.EOF;
continue;
} else {
state = State.END_OF_CONTAINER;
return reader.isInStruct()
? JsonToken.END_OBJECT
: JsonToken.END_ARRAY;
}
}
if (reader.isInStruct()) {
state = State.FIELD_NAME;
return JsonToken.FIELD_NAME;
} else {
state = State.VALUE;
return getJsonToken();
}
case END_OF_CONTAINER:
reader.stepOut();
state = State.BEFORE_VALUE;
continue;
case EOF:
return null;
case FIELD_NAME:
state = State.VALUE;
return getJsonToken();
case VALUE:
state = State.BEFORE_VALUE;
if (IonType.isContainer(reader.getType()) && !reader.isNullValue() && !shouldSkipContainer) {
reader.stepIn();
}
shouldSkipContainer = false;
continue;
}
}
}
示例15: parse
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
final JsonToken currentToken = parser.getCurrentToken();
switch( currentToken )
{
case START_OBJECT:
final Map<String, Object> oe = new MapDeserialiser().deserialize(parser, context);
if( parser.getCurrentToken() != JsonToken.END_OBJECT )
{
throw context.mappingException("Should be on end object " + where(parser, context));
}
return oe;
case VALUE_FALSE:
case VALUE_TRUE:
return parser.getValueAsBoolean();
case VALUE_NUMBER_INT:
return parser.getValueAsInt();
case VALUE_NUMBER_FLOAT:
return parser.getValueAsDouble();
case VALUE_NULL:
return "null";
case VALUE_STRING:
return "\"" + parser.getText() + "\"";
case START_ARRAY:
final Object[] ae = parseArray(parser, context);
if( parser.getCurrentToken() != JsonToken.END_ARRAY )
{
throw context.mappingException("Should be on end array " + where(parser, context));
}
return ae;
case END_ARRAY:
case END_OBJECT:
// whoops
throw context.mappingException("Unexpected end object/array " + where(parser, context));
case FIELD_NAME:
case NOT_AVAILABLE:
throw context.mappingException("How? " + where(parser, context));
default:
throw context.mappingException("Unhandled token " + where(parser, context));
}
}