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


Java JsonToken.END_ARRAY属性代码示例

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


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

示例1: parseMetricArray

private int parseMetricArray(String metric, JsonParser parser) throws IOException {
  JsonToken currentToken;
  int illegalTokens = 0;

  while ((currentToken = parser.nextToken()) != JsonToken.END_ARRAY) {

    if(!currentToken.equals(JsonToken.START_OBJECT)) {
        logger.warn("Illegal token: expected {}, but was {}: {}",
                new Object[] {JsonToken.START_OBJECT, currentToken, parser.getText()});
        illegalTokens++;
    } else {
        parseMetricObject(metric, parser);
    }

  }

  return illegalTokens;
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:18,代码来源:LegacyHttpSource.java

示例2: hasNextValue

/**
 * Equivalent of {@link #next} but one that may throw checked
 * exceptions from Jackson due to invalid input.
 */
public boolean hasNextValue() throws IOException {
    if (_parser == null) {
        return false;
    }
    JsonToken t = _parser.getCurrentToken();
    if (t == null) { // un-initialized or cleared; find next
        t = _parser.nextToken();
        // If EOF, no more
        if (t == null) {
            _parser.close();
            return false;
        }
        // And similarly if we hit END_ARRAY; except that we won't close parser
        if (t == JsonToken.END_ARRAY) {
            return false;
        }
    }
    return true;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:23,代码来源:BackportedJacksonMappingIterator.java

示例3: findDiffProp

private static void findDiffProp(JsonParser jParser) throws JsonParseException, IOException {
		String propName = null;
		String val1 = null;
		String val2 = null;
		while (jParser.nextToken() != JsonToken.END_ARRAY) {

			String fieldname = jParser.getCurrentName();
			if ("name".equals(fieldname)) {
//				System.out.println("iterating children");
				jParser.nextToken(); 
				propName = jParser.getText();
			}
			if ("value1".equals(fieldname)) {
//				System.out.println("Diff property");
				jParser.nextToken(); 
				val1 = jParser.getText();
			}
			if ("value2".equals(fieldname)) {
				jParser.nextToken(); 
				val2 = jParser.getText();
				System.out.println("Diff " + propName + " " + val1 + " -> " + val2);
				propDiffCount++;
			}
		}
		
	}
 
开发者ID:hammyau,项目名称:ODFExplorer,代码行数:26,代码来源:StyleJSONReader.java

示例4: deserialize

public short[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext);
  ArrayBuilders.ShortBuilder localShortBuilder = paramDeserializationContext.getArrayBuilders().getShortBuilder();
  short[] arrayOfShort = (short[])localShortBuilder.resetAndStart();
  int k;
  for (int i = 0; paramJsonParser.nextToken() != JsonToken.END_ARRAY; i = k)
  {
    int j = _parseShortPrimitive(paramJsonParser, paramDeserializationContext);
    if (i >= arrayOfShort.length)
    {
      arrayOfShort = (short[])localShortBuilder.appendCompletedChunk(arrayOfShort, i);
      i = 0;
    }
    k = i + 1;
    arrayOfShort[i] = j;
  }
  return (short[])localShortBuilder.completeAndClearBuffer(arrayOfShort, i);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:21,代码来源:ArrayDeserializers.java

示例5: deserialize

@Override
public List<Date> deserialize( final JsonParser parser, final DeserializationContext context )
  throws IOException
{
  if ( !parser.isExpectedStartArrayToken() )
  {
    throw context.mappingException( List.class );
  }
  final ArrayList<Date> result = new ArrayList<Date>();

  final DateFormat formatter = DateUtil.newDateFormatter();
  JsonToken token;
  while ( JsonToken.END_ARRAY != ( token = parser.nextToken() ) )
  {
    if ( JsonToken.VALUE_NULL == token )
    {
      throw context.mappingException( List.class );
    }
    result.add( DateUtil.parse( formatter, parser.getText() ) );
  }
  return result;
}
 
开发者ID:realityforge,项目名称:gwt-datatypes,代码行数:22,代码来源:DateListDeserializer.java

示例6: deserializeUsingCustom

private Collection<String> deserializeUsingCustom(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
  throws IOException, JsonProcessingException
{
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  JsonToken localJsonToken = paramJsonParser.nextToken();
  if (localJsonToken != JsonToken.END_ARRAY)
  {
    if (localJsonToken == JsonToken.VALUE_NULL);
    for (Object localObject = null; ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
    {
      paramCollection.add(localObject);
      break;
    }
  }
  return (Collection<String>)paramCollection;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:16,代码来源:StringCollectionDeserializer.java

示例7: deserialize

public Collection<String> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    paramCollection = handleNonArray(paramJsonParser, paramDeserializationContext, paramCollection);
  JsonToken localJsonToken;
  do
  {
    return paramCollection;
    if (!this._isDefaultDeserializer)
      return deserializeUsingCustom(paramJsonParser, paramDeserializationContext, paramCollection);
    localJsonToken = paramJsonParser.nextToken();
  }
  while (localJsonToken == JsonToken.END_ARRAY);
  if (localJsonToken == JsonToken.VALUE_NULL);
  for (Object localObject = null; ; localObject = paramJsonParser.getText())
  {
    paramCollection.add(localObject);
    break;
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:21,代码来源:StringCollectionDeserializer.java

示例8: deserialize

@Override
public Set<Date> deserialize( final JsonParser parser, final DeserializationContext context )
  throws IOException
{
  if ( !parser.isExpectedStartArrayToken() )
  {
    throw context.mappingException( Set.class );
  }
  final HashSet<Date> result = new HashSet<Date>();

  final DateFormat formatter = DateUtil.newDateFormatter();
  JsonToken token;
  while ( JsonToken.END_ARRAY != ( token = parser.nextToken() ) )
  {
    if ( JsonToken.VALUE_NULL == token )
    {
      throw context.mappingException( Set.class );
    }
    result.add( DateUtil.parse( formatter, parser.getText() ) );
  }
  return result;
}
 
开发者ID:realityforge,项目名称:gwt-datatypes,代码行数:22,代码来源:DateSetDeserializer.java

示例9: doArrayNext

private long doArrayNext() throws IOException {
	if (in.getCurrentToken() == JsonToken.END_ARRAY) {
		parser.advance(Symbol.ARRAY_END);
		in.nextToken();
		return 0;
	} else {
		return 1;
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:9,代码来源:ExtendedJsonDecoder.java

示例10: registJsonEntityData

/**
 * 10_relations.json, 20_roles.json, 30_extroles.json, 70_$links.json, 10_odatarelations.jsonのバリデートチェック.
 * @param jp Jsonパース
 * @param mapper ObjectMapper
 * @param jsonName ファイル名
 * @throws IOException IOException
 */
protected void registJsonEntityData(JsonParser jp, ObjectMapper mapper, String jsonName) throws IOException {
    JsonToken token;
    token = jp.nextToken();

    // Relations,Roles,ExtRoles,$linksのチェック
    checkMatchFieldName(jp, jsonName);

    token = jp.nextToken();
    // 配列でなければエラー
    if (token != JsonToken.START_ARRAY) {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
    }
    token = jp.nextToken();

    while (jp.hasCurrentToken()) {
        if (token == JsonToken.END_ARRAY) {
            break;
        } else if (token != JsonToken.START_OBJECT) {
            throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
        }

        // 1件登録処理
        JSONMappedObject mappedObject = barFileJsonValidate(jp, mapper, jsonName);
        if (jsonName.equals(RELATION_JSON)) {
            createRelation(mappedObject.getJson());
        } else if (jsonName.equals(ROLE_JSON)) {
            createRole(mappedObject.getJson());
        } else if (jsonName.equals(EXTROLE_JSON)) {
            createExtRole(mappedObject.getJson());
        } else if (jsonName.equals(LINKS_JSON)) {
            createLinks(mappedObject, odataProducer);
        }

        token = jp.nextToken();
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:43,代码来源:BarFileReadRunner.java

示例11: readIdToPendingRequests

/**
 * Reads the idToPendingRequests map from a JSON stream
 *
 * @param coronaSerializer The CoronaSerializer instance to be used to
 *                         read the JSON
 * @throws IOException
 */
private void readIdToPendingRequests(CoronaSerializer coronaSerializer)
  throws IOException {
  coronaSerializer.readField("idToPendingRequests");
  // Expecting the START_ARRAY token for idToPendingRequests
  coronaSerializer.readStartArrayToken("idToPendingRequests");
  JsonToken current = coronaSerializer.nextToken();
  while (current != JsonToken.END_ARRAY) {
    pendingRequestsList.add(coronaSerializer.jsonParser.getIntValue());
    current = coronaSerializer.nextToken();
  }
  // Done with reading the END_ARRAY token for idToPendingRequests
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:19,代码来源:Session.java

示例12: readTransaction

private static Transaction readTransaction(JsonParser jParser) throws IOException {
    long creationTimestamp = 0;
    long id = 0;
    List<Task> preparedTasks = new ArrayList<>();
    while (jParser.nextToken() != JsonToken.END_OBJECT) {

        switch (jParser.getCurrentName() + "") {
            case "creationTimestamp":
                nextToken(jParser);
                creationTimestamp = Long.parseLong(readValue(jParser));
                break;
            case "id":
                nextToken(jParser);
                id = Long.parseLong(readValue(jParser));
                break;
            case "preparedTasks":
                nextToken(jParser);
                while (jParser.nextToken() != JsonToken.END_ARRAY) {
                    Task task = readTask(jParser);
                    preparedTasks.add(task);
                }
                break;
            default:
                throw new IOException("Unexpected field " + jParser.getCurrentName());
        }
    }
    Transaction res = new Transaction(id, creationTimestamp);
    if (!preparedTasks.isEmpty()) {
        res.getPreparedTasks().addAll(preparedTasks);
    }
    return res;

}
 
开发者ID:diennea,项目名称:majordodo,代码行数:33,代码来源:BrokerStatusSnapshot.java

示例13: findDiffNode

private static void findDiffNode(JsonParser jParser) throws JsonParseException, IOException {
		String nodeName = null;
		while (jParser.nextToken() != JsonToken.END_ARRAY) {

			String fieldname1 = jParser.getCurrentName();
			if ("name".equals(fieldname1)) {
				jParser.nextToken(); 
				nodeName = jParser.getText();
			}
			if ("hits".equals(fieldname1)) {
				jParser.nextToken(); //the [
				jParser.skipChildren();
				System.out.println("Node " + nodeName + " hit");
			}
			if ("diff".equals(fieldname1)) {
				jParser.nextToken(); 
				String diff = jParser.getText();
				if(!"SameStyle".equals(diff)) {
					System.out.println("found diff node " + nodeName + ":" + diff);
					if(nodeName.contains("Properties")) {
						findDiffProperties(jParser);
					}
					else {
						findDiffChildren(jParser);
					}
				}
				else {
//					System.out.println("Skipping node " + nodeName);
					findSkipChildren(jParser);
				}
			}
			if (fieldname1 != null && fieldname1.contains("children")) {
//				System.out.println("Skipping children of " + nodeName);
				jParser.nextToken(); // current token is "[", move next
				jParser.skipChildren();
			}
		}

	}
 
开发者ID:hammyau,项目名称:ODFExplorer,代码行数:39,代码来源:StyleJSONReader.java

示例14: doArrayNext

private long doArrayNext() throws IOException {
  if (in.getCurrentToken() == JsonToken.END_ARRAY) {
    parser.advance(Symbol.ARRAY_END);
    in.nextToken();
    return 0;
  } else {
    return 1;
  }
}
 
开发者ID:openaire,项目名称:iis,代码行数:9,代码来源:HackedJsonDecoder.java

示例15: processing

public void processing(Callback callback) throws IOException {
    JsonToken current = parser.nextToken();

    /** the following read from a big json array **/
    if (current == JsonToken.START_ARRAY) {
        // For each of the records in the array
        while (parser.nextToken() != JsonToken.END_ARRAY) {
            // read the record into a tree model,
            // this moves the parsing position to the end of it
            JsonNode node = parser.readValueAsTree();
            callback.processSingleJSONRecord(node);
        }
    }
}
 
开发者ID:NCBI-Hackathons,项目名称:seqr,代码行数:14,代码来源:JsonStreamParser.java


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