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


Java JsonParser.getText方法代碼示例

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


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

示例1: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

    // validate enum class
    if (enumClass == null) {
        throw new JsonMappingException("Unable to parse unknown pick-list type");
    }

    final String listValue = jp.getText();

    try {
        // parse the string of the form value1;value2;...
        final String[] value = listValue.split(";");
        final int length = value.length;
        final Object resultArray = Array.newInstance(enumClass, length);
        for (int i = 0; i < length; i++) {
            // use factory method to create object
            Array.set(resultArray, i, factoryMethod.invoke(null, value[i].trim()));
        }

        return resultArray;
    } catch (Exception e) {
        throw new JsonParseException("Exception reading multi-select pick list value", jp.getCurrentLocation(), e);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:26,代碼來源:MultiSelectPicklistDeserializer.java

示例2: getSpecificJSONValue

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private String getSpecificJSONValue(HttpResponse response, String jsonKey) throws JsonParseException, IllegalStateException, IOException {
	InputStream content = response.getEntity().getContent();
	if (isSuccessfulResponse(response)) {
		JsonFactory f = new JsonFactory();
		JsonParser jp = f.createJsonParser(content);
		while ((jp.nextToken()) != JsonToken.END_OBJECT) {
			if (jsonKey.equals(jp.getCurrentName())) {
				jp.nextToken();
				return jp.getText();
			}
		}
	} else {
		String string = IOUtils.toString(content);
		System.err.println(string);
	}
	return null;
}
 
開發者ID:ExLibrisGroup,項目名稱:Rosetta.NetAppStoragePlugin,代碼行數:18,代碼來源:CDMIConnector.java

示例3: findDiffProp

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
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,代碼行數:27,代碼來源:StyleJSONReader.java

示例4: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public MACAddress deserialize(JsonParser jp,
                              DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    MACAddress mac = null;

    jp.nextToken();        // Move to JsonToken.START_OBJECT
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = jp.getCurrentName();
        if ("value".equals(fieldname)) {
            String value = jp.getText();
            log.debug("Fieldname: {} Value: {}", fieldname, value);
            mac = MACAddress.valueOf(value);
        }
    }
    return mac;
}
 
開發者ID:opennetworkinglab,項目名稱:spring-open,代碼行數:19,代碼來源:MACAddressDeserializer.java

示例5: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public Character deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    int i = paramJsonParser.getIntValue();
    if ((i >= 0) && (i <= 65535))
      return Character.valueOf((char)i);
  }
  else if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    if (str.length() == 1)
      return Character.valueOf(str.charAt(0));
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:StdDeserializer.java

示例6: getAsJsonString

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private Object getAsJsonString(JsonParser jp) throws JsonParseException,
		IOException {
	String asString = "";
	JsonToken token = jp.getCurrentToken();

	while (!token.equals(JsonToken.END_OBJECT)) {

		String key = jp.getText();
		token = jp.nextToken();
		String value = jp.getText();
		String.format("\"%s\" : \"%s\"", key, value);

		if (asString.isEmpty()) {
			asString += String.format("\"%s\" : \"%s\"", key, value);
		} else {
			asString += String.format(", \"%s\" : \"%s\"", key, value);
		}
		token = jp.nextToken();
	}
	asString = String.format("{%s}", asString);
	return asString;
}
 
開發者ID:Aeronbroker,項目名稱:Aeron,代碼行數:23,代碼來源:MetadataValueDeserializer.java

示例7: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public Object deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() != JsonToken.VALUE_STRING)
    throw paramDeserializationContext.mappingException(this._enumClass);
  String str = paramJsonParser.getText();
  try
  {
    Object localObject = this._factory.invoke(this._enumClass, new Object[] { str });
    return localObject;
  }
  catch (Exception localException)
  {
    ClassUtil.unwrapAndThrowAsIAE(localException);
  }
  return null;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:18,代碼來源:EnumDeserializer.java

示例8: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
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,代碼行數:22,代碼來源:StringCollectionDeserializer.java

示例9: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public Date deserialize( JsonParser jsonparser, DeserializationContext arg1 )
    throws IOException, JsonProcessingException
{
    SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
    String date = jsonparser.getText();
    try
    {
        return format.parse( date );
    }
    catch ( ParseException e )
    {
        throw new RuntimeException( e );
    }
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:16,代碼來源:JsonDateDeserializer.java

示例10: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public Date deserialize(JsonParser jp, org.codehaus.jackson.map.DeserializationContext dc) throws IOException, JsonProcessingException {
       String date = jp.getText();

       if (StrUtils.isNumber(date)) {
           long l = Long.parseLong(date);
           return new Date(l); 
       } else {
           Date dt = DateUtils.getDateByString(Const.DATE_FORMAT, date);
           return dt;
       }
   }
 
開發者ID:mwambler,項目名稱:xockets.io,代碼行數:13,代碼來源:CustomDateDeserializer.java

示例11: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public LocalDate deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws JsonParseException, IOException
{
    final String text = parser.getText();
    if (text == null)
    {
        return null;
    }
    return new LocalDate(text);
}
 
開發者ID:NovaOrdis,項目名稱:playground,代碼行數:12,代碼來源:LocalDateDeserializer.java

示例12: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public Date deserialize(JsonParser jsonparser,
                        DeserializationContext deserializationcontext) throws IOException, JsonProcessingException {

    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    String date = jsonparser.getText();
    try {
        return format.parse(date);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }

}
 
開發者ID:Ellychou,項目名稱:Todo-Jersey-Spring-MyBatis,代碼行數:14,代碼來源:CustomJsonDateDeserializer.java

示例13: getResponseMetadata

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private HashMap<String, String> getResponseMetadata(HttpResponse response, String identifier) throws JsonParseException, IllegalStateException, IOException {
	HashMap<String, String> metadata = new HashMap<String, String>();
	InputStream content = response.getEntity().getContent();
	if (isSuccessfulResponse(response)) {
		String key, value = null;
		JsonFactory f = new JsonFactory();
		JsonParser jp = f.createJsonParser(content);
		while ((jp.nextToken()) != JsonToken.END_OBJECT) {
			key = jp.getCurrentName();
			if ("metadata".equals(key)) {
				jp.nextToken();
				System.out.println("Start parsing metadata for " + identifier);
				while ((jp.nextToken()) != JsonToken.END_OBJECT) {
					key = jp.getCurrentName();
					jp.nextToken();
					value = jp.getText();
					metadata.put(key, value);
					System.out.println(identifier + " -- Key = " + key + " : Value = " + value);
				}
				System.out.println("End parsing metadata for " + identifier);
				return metadata;
			}
		}
	} else {
		String string = IOUtils.toString(content);
		System.err.println(string);
	}
	return metadata;
}
 
開發者ID:ExLibrisGroup,項目名稱:Rosetta.NetAppStoragePlugin,代碼行數:30,代碼來源:CDMIConnector.java

示例14: jsonToHostDefinition

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
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,代碼行數:39,代碼來源:HostResource.java

示例15: getEntryNameFromJson

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
/**
 * 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,代碼行數:38,代碼來源:StaticFlowEntries.java


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