本文整理匯總了Java中org.codehaus.jackson.JsonParser.getTextLength方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getTextLength方法的具體用法?Java JsonParser.getTextLength怎麽用?Java JsonParser.getTextLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.jackson.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getTextLength方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserializeFromString
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public Object deserializeFromString(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (this._stringCreator != null)
return this._stringCreator.construct(paramJsonParser.getText());
if (this._delegatingCreator != null)
return this._delegatingCreator.deserialize(paramJsonParser, paramDeserializationContext);
if ((paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) && (paramJsonParser.getTextLength() == 0))
return null;
throw paramDeserializationContext.instantiationException(getBeanClass(), "no suitable creator method found to deserialize from JSON String");
}
示例2: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public char[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
if (localJsonToken1 == JsonToken.VALUE_STRING)
{
char[] arrayOfChar1 = paramJsonParser.getTextCharacters();
int i = paramJsonParser.getTextOffset();
int j = paramJsonParser.getTextLength();
char[] arrayOfChar2 = new char[j];
System.arraycopy(arrayOfChar1, i, arrayOfChar2, 0, j);
return arrayOfChar2;
}
if (paramJsonParser.isExpectedStartArrayToken())
{
StringBuilder localStringBuilder = new StringBuilder(64);
while (true)
{
JsonToken localJsonToken2 = paramJsonParser.nextToken();
if (localJsonToken2 == JsonToken.END_ARRAY)
break;
if (localJsonToken2 != JsonToken.VALUE_STRING)
throw paramDeserializationContext.mappingException(Character.TYPE);
String str = paramJsonParser.getText();
if (str.length() != 1)
throw JsonMappingException.from(paramJsonParser, "Can not convert a JSON String of length " + str.length() + " into a char element of char array");
localStringBuilder.append(str.charAt(0));
}
return localStringBuilder.toString().toCharArray();
}
if (localJsonToken1 == JsonToken.VALUE_EMBEDDED_OBJECT)
{
Object localObject = paramJsonParser.getEmbeddedObject();
if (localObject == null)
return null;
if ((localObject instanceof char[]))
return (char[])(char[])localObject;
if ((localObject instanceof String))
return ((String)localObject).toCharArray();
if ((localObject instanceof byte[]))
return Base64Variants.getDefaultVariant().encode((byte[])(byte[])localObject, false).toCharArray();
}
throw paramDeserializationContext.mappingException(this._valueClass);
}