本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
示例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));
}
}