本文整理汇总了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);
}