當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。