本文整理匯總了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);
}
}
示例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;
}
示例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++;
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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 );
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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