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


Java JsonToken.START_ARRAY属性代码示例

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


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

示例1: RaceTrack

RaceTrack(String filename) throws IOException {
    ClassLoader classLoader = getClass().getClassLoader();

    double len = 0.0;
    try (JsonParser parser = new JsonFactory().createParser(classLoader.getResource(filename))) {
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            if (Objects.equals(parser.getCurrentName(), "parts")) {
                // We found parts so load them
                if (parser.nextToken() != JsonToken.START_ARRAY) {
                    throw new IOException("Array expected.");
                }
                int index = 0;
                while (parser.nextToken() == JsonToken.START_OBJECT) {
                    Part part = loadPart(index, parser, len);
                    len += part.length;
                    parts.add(part);
                    index += 1;
                }
                break;
            }
        }
    }

    length = len;
    trackFile = filename;
}
 
开发者ID:pushtechnology,项目名称:racing-demo,代码行数:26,代码来源:RaceTrack.java

示例2: parseField

@Override
public void parseField(LowerCaseNamingPolicyModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("camel_case_list".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.camelCaseList = collection1;
        } else{
            instance.camelCaseList = null;
        }
    } else if ("camel_case_string".equals(fieldName)){
        instance.camelCaseString = jsonParser.getValueAsString(null);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:LowerCaseNamingPolicyModel$$JsonObjectMapper.java

示例3: deserialize

public static YieldMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	long request = jp.getLongValue();

	jp.nextToken();
	ParserUtil.readObject(jp);

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new YieldMessage(request, arguments, argumentsKw);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:21,代码来源:YieldMessage.java

示例4: readArray

@Nullable
public static List<Object> readArray(JsonParser jp) throws IOException {
	if (jp.currentToken() != JsonToken.START_ARRAY) {
		return null;
	}

	List<Object> result = new ArrayList<>();
	JsonToken token = jp.nextToken();
	while (token != JsonToken.END_ARRAY) {

		if (token == JsonToken.START_ARRAY) {
			result.add(readArray(jp));
		}
		else if (token == JsonToken.START_OBJECT) {
			result.add(readObject(jp));
		}
		else {
			result.add(getValue(jp));
		}

		token = jp.nextToken();
	}

	return result;
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:25,代码来源:ParserUtil.java

示例5: getJsonToken

private JsonToken getJsonToken() {
    if (reader.isNullValue()) {
        return JsonToken.VALUE_NULL;
    }

    IonType currentType = reader.getType();
    switch (currentType) {
        case BLOB:
        case CLOB:
            return JsonToken.VALUE_EMBEDDED_OBJECT;
        case BOOL:
            return reader.booleanValue() ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE;
        case DECIMAL:
            return JsonToken.VALUE_NUMBER_FLOAT;
        case FLOAT:
            return JsonToken.VALUE_NUMBER_FLOAT;
        case INT:
            return JsonToken.VALUE_NUMBER_INT;
        case LIST:
            return JsonToken.START_ARRAY;
        case SEXP:
            return JsonToken.START_ARRAY;
        case STRING:
            return JsonToken.VALUE_STRING;
        case STRUCT:
            return JsonToken.START_OBJECT;
        case SYMBOL:
            return JsonToken.VALUE_STRING;
        case TIMESTAMP:
            return JsonToken.VALUE_EMBEDDED_OBJECT;
        default:
            throw new SdkClientException(String.format("Unhandled Ion type %s", currentType));
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:34,代码来源:IonParser.java

示例6: parseList

/**
 * Parse a list of objects from a JsonParser.
 *
 * @param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token.
 */
public List<T> parseList(JsonParser jsonParser) throws IOException {
    List<T> list = new ArrayList<>();
    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            list.add(parse(jsonParser));
        }
    }
    return list;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:JsonMapper.java

示例7: getToken

private JsonToken getToken(final ValueType type, final VPackSlice value) {
	final JsonToken token;
	switch (type) {
	case OBJECT:
		token = JsonToken.START_OBJECT;
		break;
	case ARRAY:
		token = JsonToken.START_ARRAY;
		break;
	case STRING:
		token = JsonToken.VALUE_STRING;
		break;
	case BOOL:
		token = value.isTrue() ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE;
		break;
	case DOUBLE:
		token = JsonToken.VALUE_NUMBER_FLOAT;
		break;
	case INT:
	case SMALLINT:
	case UINT:
		token = JsonToken.VALUE_NUMBER_INT;
		break;
	case NULL:
		token = JsonToken.VALUE_NULL;
		break;
	default:
		token = null;
		break;
	}
	return token;
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:32,代码来源:VPackParser.java

示例8: deserialize

public static ErrorMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	int type = jp.getIntValue();

	jp.nextToken();
	long request = jp.getLongValue();

	jp.nextToken();
	ParserUtil.readObject(jp);

	jp.nextToken();
	String error = jp.getValueAsString();

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new ErrorMessage(type, request, error, arguments, argumentsKw);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:27,代码来源:ErrorMessage.java

示例9: deserialize

public static InvocationMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	long request = jp.getLongValue();

	jp.nextToken();
	long registration = jp.getLongValue();

	jp.nextToken();
	Number caller = null;
	Map<String, Object> details = ParserUtil.readObject(jp);
	if (details != null) {
		caller = (Number) details.get("caller");
	}

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new InvocationMessage(request, registration, caller, arguments,
			argumentsKw);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:29,代码来源:InvocationMessage.java

示例10: parse

@Override
public RealmList<T> parse(JsonParser jsonParser) throws IOException {
    init();
    RealmList<T> list = new RealmList<>();
    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            T object = typeConverter != null ? typeConverter.parse(jsonParser) : mapper.parse(jsonParser);
            if (object != null) {
                list.add(object);
            }
        }
    }
    return list;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:14,代码来源:RealmListLoganSquareConverter.java

示例11: deserializeImpl

private String deserializeImpl(JsonParser p, DeserializationContext ctxt) throws IOException
{
    if (p.hasToken(JsonToken.VALUE_STRING))
    {
        return p.getText();
    }
    JsonToken t = p.getCurrentToken();
    // [databind#381]
    if (t == JsonToken.START_ARRAY) {
        return _deserializeFromArray(p, ctxt);
    }
    // need to gracefully handle byte[] data, as base64
    if (t == JsonToken.VALUE_EMBEDDED_OBJECT) {
        Object ob = p.getEmbeddedObject();
        if (ob == null) {
            return null;
        }
        if (ob instanceof byte[]) {
            return ctxt.getBase64Variant().encode((byte[]) ob, false);
        }
        // otherwise, try conversion using toString()...
        return ob.toString();
    }
    // allow coercions for other scalar types
    String text = p.getValueAsString();
    if (text != null) {
        return text;
    }
    return (String) ctxt.handleUnexpectedToken(_valueClass, p);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:RestApiStringDeserializer.java

示例12: deserialize

public static EventMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	long subscription = jp.getLongValue();

	jp.nextToken();
	long publication = jp.getLongValue();

	jp.nextToken();
	String topic = null;
	Number publisher = null;
	boolean retained = false;
	Map<String, Object> details = ParserUtil.readObject(jp);
	if (details != null) {
		topic = (String) details.get("topic");
		publisher = (Number) details.get("publisher");
		retained = (boolean) details.getOrDefault("retained", false);
	}

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new EventMessage(subscription, publication, topic, publisher, retained,
			arguments, argumentsKw);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:33,代码来源:EventMessage.java

示例13: writeDeclaredList

private void writeDeclaredList(ListWriter list, FieldSelection selection, FieldReadDefinition readDef, SchemaPath path, boolean startList, boolean allowNestList) throws IOException {
  if(startList && allowNestList){
    list.startList();
  }
  while (true) {
    try {
      JsonToken token = parser.nextToken();
      if (token == JsonToken.START_ARRAY) {
        boolean innerAllowNestList = readDef.isArray() || readDef.isGeo();
        writeDeclaredList(innerAllowNestList ? list.list() : list, selection, readDef, path, true, innerAllowNestList);
      } else if (token == JsonToken.END_ARRAY) {
        break;
      } else if (token == JsonToken.END_OBJECT) {
        continue;
      } else if (token == JsonToken.START_OBJECT) {
        writeDeclaredMap(list.map(), selection, readDef, true, path, false);
      } else {
        readDef.writeList(list, token, parser);
      }
    } catch (Exception e) {
      throw getExceptionWithContext(e, this.currentFieldName, null).build(logger);
    }
  }

  if(startList && allowNestList){
    list.endList();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:ElasticsearchJsonReader.java

示例14: parseArrayStart

/** Checks whether the current token is '[' and advances past it. */
static void parseArrayStart(JsonParser parser) throws IOException {
  JsonToken json = parser.currentToken();
  if (json != JsonToken.START_ARRAY) {
    throw new InvalidProtocolBufferException("Expected an array but found: " + json);
  }
  parser.nextToken();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:8,代码来源:ParseSupport.java

示例15: deserialize

@Override
public Nullable<Object> deserialize(JsonParser jp, DeserializationContext context) throws IOException {
	JsonToken currentToken = jp.getCurrentToken();
	if (currentToken == JsonToken.START_ARRAY) {
		ResourceIdentifier[] resources = jp.readValueAs(ResourceIdentifier[].class);
		return Nullable.of((Object) Arrays.asList(resources));
	}
	else if (currentToken == JsonToken.VALUE_NULL) {
		return Nullable.of(null);
	}
	else {
		PreconditionUtil.assertEquals("parsing failed", currentToken, JsonToken.START_OBJECT);
		return Nullable.of((Object) jp.readValueAs(ResourceIdentifier.class));
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:15,代码来源:RelationshipDataDeserializer.java


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