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


Java JsonToken.FIELD_NAME屬性代碼示例

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


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

示例1: readString

@Override
public String readString() throws IOException {
	advance(Symbol.STRING);
	if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
		parser.advance(Symbol.MAP_KEY_MARKER);
		if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw error("map-key");
		}
	} else {
		if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
			throw error("string");
		}
	}
	String result = in.getText();
	in.nextToken();
	return result;
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:17,代碼來源:ExtendedJsonDecoder.java

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

示例3: readString

@Override
public String readString() throws IOException {
  advance(Symbol.STRING);
  if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
    parser.advance(Symbol.MAP_KEY_MARKER);
    if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
      throw error("map-key");
    }
  } else {
    if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
      throw error("string");
    }
  }
  String result = in.getText();
  in.nextToken();
  return result;
}
 
開發者ID:openaire,項目名稱:iis,代碼行數:17,代碼來源:HackedJsonDecoder.java

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

示例5: nextToken

public JsonToken nextToken()
{
  if (this._needEntry)
  {
    if (!this._contents.hasNext())
    {
      this._current = null;
      return null;
    }
    this._needEntry = false;
    this._current = ((Map.Entry)this._contents.next());
    return JsonToken.FIELD_NAME;
  }
  this._needEntry = true;
  return ((JsonNode)this._current.getValue()).asToken();
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:16,代碼來源:NodeCursor.java

示例6: skipString

@Override
public void skipString() throws IOException {
	advance(Symbol.STRING);
	if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
		parser.advance(Symbol.MAP_KEY_MARKER);
		if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw error("map-key");
		}
	} else {
		if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
			throw error("string");
		}
	}
	in.nextToken();
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:15,代碼來源:ExtendedJsonDecoder.java

示例7: getFieldName

/**
 * If the current token is a field name, this method returns the name of
 * the field.
 *
 * @return A String object containing the name of the field
 * @throws IOException
 */
public String getFieldName() throws IOException {
  if (jsonParser.getCurrentToken() != JsonToken.FIELD_NAME) {
    throw new IOException("Expected a field of type " + JsonToken.FIELD_NAME +
                          ", but found a field of type " +
                          jsonParser.getCurrentToken());
  }
  return jsonParser.getCurrentName();
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:15,代碼來源:CoronaSerializer.java

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

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

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

示例11: checkField

private void checkField(String field) throws JsonParseException,
        IOException {
	if (!(this.parser.getCurrentToken() == JsonToken.FIELD_NAME && field
	        .equals(this.parser.getCurrentName()))) {
		fail(field);
	} else {
		nextValue();
	}
}
 
開發者ID:eurekaclinical,項目名稱:eureka,代碼行數:9,代碼來源:SliceAbstractionJsonDeserializer.java

示例12: checkField

private void checkField(String field) throws JsonParseException,
		IOException {
	if (!(this.parser.getCurrentToken() == JsonToken.FIELD_NAME && field
			.equals(this.parser.getCurrentName()))) {
		fail(field);
	} else {
		nextValue();
	}
}
 
開發者ID:eurekaclinical,項目名稱:eureka,代碼行數:9,代碼來源:CompoundLowLevelAbstractionJsonDeserializer.java

示例13: skipString

@Override
public void skipString() throws IOException {
  advance(Symbol.STRING);
  if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
    parser.advance(Symbol.MAP_KEY_MARKER);
    if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
      throw error("map-key");
    }
  } else {
    if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
      throw error("string");
    }
  }
  in.nextToken();
}
 
開發者ID:openaire,項目名稱:iis,代碼行數:15,代碼來源:HackedJsonDecoder.java

示例14: 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 (isUnionOfNullWithSomething(a)){
    	int nullN = a.findLabel("null");
    	int otherN = (nullN+1)%2;
//    	parser.pushSymbol(Symbol.UNION_END);
    	parser.pushSymbol(a.getSymbol(otherN));
    	return otherN;
    } 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:openaire,項目名稱:iis,代碼行數:28,代碼來源:HackedJsonDecoder.java

示例15: _deserialize

private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.START_OBJECT, "need JSON Object to contain As.WRAPPER_OBJECT type information for class " + baseTypeName());
  if (paramJsonParser.nextToken() != JsonToken.FIELD_NAME)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.FIELD_NAME, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")");
  JsonDeserializer localJsonDeserializer = _findDeserializer(paramDeserializationContext, paramJsonParser.getText());
  paramJsonParser.nextToken();
  Object localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  if (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_OBJECT, "expected closing END_OBJECT after type information and deserialized value");
  return localObject;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:14,代碼來源:AsWrapperTypeDeserializer.java


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