本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.getCurrentLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getCurrentLocation方法的具体用法?Java JsonParser.getCurrentLocation怎么用?Java JsonParser.getCurrentLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getCurrentLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public I18NStrings deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException
{
Map<String, LanguageString> strings = Maps.newHashMap();
JsonToken currentToken = jp.getCurrentToken();
if( currentToken != JsonToken.START_OBJECT )
{
throw new JsonParseException("Must be an object", jp.getCurrentLocation());
}
while( jp.nextToken() == JsonToken.FIELD_NAME )
{
String textValue = jp.nextTextValue();
LanguageBundle tempBundle = LangUtils.createTempLangugageBundle(null, textValue);
LanguageString tempLangString = LangUtils.createLanguageString(tempBundle, CurrentLocale.getLocale(),
textValue);
strings.put(jp.getCurrentName(), tempLangString);
}
return new SimpleI18NStrings(strings);
}
示例2: testLocation
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public void testLocation() throws Exception
{
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createParser(ObjectReadContext.empty(), " { }");
assertToken(JsonToken.START_OBJECT, jp.nextToken());
JsonLocation loc = jp.getCurrentLocation();
byte[] stuff = jdkSerialize(loc);
JsonLocation loc2 = jdkDeserialize(stuff);
assertNotNull(loc2);
assertEquals(loc.getLineNr(), loc2.getLineNr());
assertEquals(loc.getColumnNr(), loc2.getColumnNr());
jp.close();
}
示例3: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public LineString deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
Geometry geom = parse(jp);
if(geom instanceof LineString) {
return (LineString)geom;
}
throw new JsonParseException(jp, "parsed geometry was not a LineString!", jp.getCurrentLocation());
}
示例4: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Geometry parse(JsonParser jp) throws IOException, JsonProcessingException {
WKTReader reader = new WKTReader();
Geometry geom;
try {
geom = reader.read(jp.getText());
} catch (ParseException e) {
throw new JsonParseException(jp, "wkt not parsable", jp.getCurrentLocation(), e);
}
return geom;
}
示例5: throwE
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private static void throwE(JsonParser jp, String e) throws JsonParseException {
throw new JsonParseException(e, jp.getCurrentLocation());
}