當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonToken.START_OBJECT屬性代碼示例

本文整理匯總了Java中org.codehaus.jackson.JsonToken.START_OBJECT屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonToken.START_OBJECT屬性的具體用法?Java JsonToken.START_OBJECT怎麽用?Java JsonToken.START_OBJECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.codehaus.jackson.JsonToken的用法示例。


在下文中一共展示了JsonToken.START_OBJECT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readIndex

@Override
public int readIndex() throws IOException {
	advance(Symbol.UNION);
	Symbol.Alternative a = (Symbol.Alternative) parser.popSymbol();
	
	String label;
	if (in.getCurrentToken() == JsonToken.VALUE_NULL) {
		label = "null";
	} else if (in.getCurrentToken() == JsonToken.START_OBJECT &&
			in.nextToken() == JsonToken.FIELD_NAME) {
		label = in.getText();
		in.nextToken();
		parser.pushSymbol(Symbol.UNION_END);
	} else {
		throw error("start-union");
	}
	int n = a.findLabel(label);
	if (n < 0)
		throw new AvroTypeException("Unknown union branch " + label);
	parser.pushSymbol(a.getSymbol(n));
	return n;
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:22,代碼來源:ExtendedJsonDecoder.java

示例2: readJsonEntry

/**
 * barファイルエントリからJSONファイルを読み込む.
 * @param <T> JSONMappedObject
 * @param inStream barファイルエントリのInputStream
 * @param entryName entryName
 * @param clazz clazz
 * @return JSONファイルから読み込んだオブジェクト
 * @throws IOException JSONファイル読み込みエラー
 */
public static <T> T readJsonEntry(
        InputStream inStream, String entryName, Class<T> clazz) throws IOException {
    JsonParser jp = null;
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory f = new JsonFactory();
    jp = f.createJsonParser(inStream);
    JsonToken token = jp.nextToken(); // JSONルート要素("{")
    Pattern formatPattern = Pattern.compile(".*/+(.*)");
    Matcher formatMatcher = formatPattern.matcher(entryName);
    String jsonName = formatMatcher.replaceAll("$1");
    T json = null;
    if (token == JsonToken.START_OBJECT) {
        try {
            json = mapper.readValue(jp, clazz);
        } catch (UnrecognizedPropertyException ex) {
            throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
        }
    } else {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
    }
    return json;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:31,代碼來源:BarFileUtils.java

示例3: getRequestBody

/**
 * リクエストボディを解析してEventオブジェクトを取得する.
 * @param reader Http入力ストリーム
 * @return 解析したEventオブジェクト
 */
protected JSONEvent getRequestBody(final Reader reader) {
    JSONEvent event = null;
    JsonParser jp = null;
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory f = new JsonFactory();
    try {
        jp = f.createJsonParser(reader);
        JsonToken token = jp.nextToken(); // JSONルート要素("{")
        if (token == JsonToken.START_OBJECT) {
            event = mapper.readValue(jp, JSONEvent.class);
        } else {
            throw PersoniumCoreException.Event.JSON_PARSE_ERROR;
        }
    } catch (IOException e) {
        throw PersoniumCoreException.Event.JSON_PARSE_ERROR;
    }
    return event;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:23,代碼來源:EventResource.java

示例4: parse

public void parse(HttpRequest req) throws IOException {

      final JsonParser parser = jsonFactory.createJsonParser(
              new ChannelBufferInputStream(req.getContent()));

      parser.nextToken(); // Skip the wrapper

      while (parser.nextToken() != JsonToken.END_OBJECT) {

        final String metric = parser.getCurrentName();

        JsonToken currentToken = parser.nextToken();
        if (currentToken == JsonToken.START_OBJECT) {
          parseMetricObject(metric, parser);
        } else if (currentToken == JsonToken.START_ARRAY) {
          int illegalTokens = parseMetricArray(metric, parser);
          if(illegalTokens > 0) {
              logger.warn("{} illegal tokens encountered", illegalTokens);
          }
        } else {
          logger.warn("Illegal token: expected {} or {}, but was {}: {}",new Object[] {
                  JsonToken.START_OBJECT, JsonToken.START_ARRAY, currentToken, parser.getText()});
        }
      }
    }
 
開發者ID:yandex,項目名稱:opentsdb-flume,代碼行數:25,代碼來源:LegacyHttpSource.java

示例5: test3

@Test
public void test3() throws JsonParseException, IOException {
	ObjectMapper mapper = new ObjectMapper();
	String json = "[{\"foo\": \"bar\"},{\"foo\": \"biz\"}]";
	
	JsonFactory f = new JsonFactory();
	JsonParser jp = f.createJsonParser(json);
	// advance stream to START_ARRAY first:
	jp.nextToken();
	// and then each time, advance to opening START_OBJECT
	while (jp.nextToken() == JsonToken.START_OBJECT) {
		Foo foobar = mapper.readValue(jp, Foo.class);
		// process
		// after binding, stream points to closing END_OBJECT
		
		System.out.println(foobar);
	}
}
 
開發者ID:liuxianqiang,項目名稱:jackson-in-five-minutes,代碼行數:18,代碼來源:StreamAPI.java

示例6: _nextAfterName

private final JsonToken _nextAfterName()
{
  this._nameCopied = false;
  JsonToken localJsonToken = this._nextToken;
  this._nextToken = null;
  if (localJsonToken == JsonToken.START_ARRAY)
    this._parsingContext = this._parsingContext.createChildArrayContext(this._tokenInputRow, this._tokenInputCol);
  while (true)
  {
    this._currToken = localJsonToken;
    return localJsonToken;
    if (localJsonToken != JsonToken.START_OBJECT)
      continue;
    this._parsingContext = this._parsingContext.createChildObjectContext(this._tokenInputRow, this._tokenInputCol);
  }
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:16,代碼來源:Utf8StreamParser.java

示例7: deserialize

public EnumMap<?, ?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
    throw paramDeserializationContext.mappingException(EnumMap.class);
  EnumMap localEnumMap = constructMap();
  if (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
  {
    String str = paramJsonParser.getCurrentName();
    Enum localEnum = this._enumResolver.findEnum(str);
    if (localEnum == null)
      throw paramDeserializationContext.weirdStringException(this._enumResolver.getEnumClass(), "value not one of declared Enum instance names");
    if (paramJsonParser.nextToken() == JsonToken.VALUE_NULL);
    for (Object localObject = null; ; localObject = this._valueDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
    {
      localEnumMap.put(localEnum, localObject);
      break;
    }
  }
  return localEnumMap;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:21,代碼來源:EnumMapDeserializer.java

示例8: deserializeObject

protected final ObjectNode deserializeObject(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  ObjectNode localObjectNode = paramDeserializationContext.getNodeFactory().objectNode();
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.START_OBJECT);
  for (localJsonToken = paramJsonParser.nextToken(); localJsonToken == JsonToken.FIELD_NAME; localJsonToken = paramJsonParser.nextToken())
  {
    String str = paramJsonParser.getCurrentName();
    paramJsonParser.nextToken();
    JsonNode localJsonNode1 = deserializeAny(paramJsonParser, paramDeserializationContext);
    JsonNode localJsonNode2 = localObjectNode.put(str, localJsonNode1);
    if (localJsonNode2 == null)
      continue;
    _handleDuplicateField(str, localObjectNode, localJsonNode2, localJsonNode1);
  }
  return localObjectNode;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:18,代碼來源:BaseNodeDeserializer.java

示例9: readMapStart

@Override
public long readMapStart() throws IOException {
	advance(Symbol.MAP_START);
	if (in.getCurrentToken() == JsonToken.START_OBJECT) {
		in.nextToken();
		return doMapNext();
	} else {
		throw error("map-start");
	}
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:10,代碼來源:ExtendedJsonDecoder.java

示例10: skipMap

@Override
public long skipMap() throws IOException {
	advance(Symbol.MAP_START);
	if (in.getCurrentToken() == JsonToken.START_OBJECT) {
		in.skipChildren();
		in.nextToken();
		advance(Symbol.MAP_END);
	} else {
		throw error("map-start");
	}
	return 0;
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:12,代碼來源:ExtendedJsonDecoder.java

示例11: 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

示例12: jsonToHostDefinition

protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }
    
    jp.close();
}
 
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:38,代碼來源:HostResource.java

示例13: getEntryNameFromJson

/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        
        if (n == "name")
            return jp.getText();
    }
    
    return null;
}
 
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:37,代碼來源:StaticFlowEntries.java

示例14: jsonExtractSubnetMask

/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
 
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:40,代碼來源:FirewallResource.java

示例15: readMapStart

@Override
public long readMapStart() throws IOException {
  advance(Symbol.MAP_START);
  if (in.getCurrentToken() == JsonToken.START_OBJECT) {
    in.nextToken();
    return doMapNext();
  } else {
    throw error("map-start");
  }
}
 
開發者ID:openaire,項目名稱:iis,代碼行數:10,代碼來源:HackedJsonDecoder.java


注:本文中的org.codehaus.jackson.JsonToken.START_OBJECT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。