本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.getCurrentToken方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getCurrentToken方法的具体用法?Java JsonParser.getCurrentToken怎么用?Java JsonParser.getCurrentToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getCurrentToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public SimpleGenericModel<T> parse(JsonParser jsonParser) throws IOException {
SimpleGenericModel<T> instance = new SimpleGenericModel<T>();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
示例2: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public List<T> deserialize(InputStream stream) throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
List<T> segments = new ArrayList<T>();
JsonToken token = jp.nextToken();
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
segments.add(processSegment(jp, adapter));
}
}
log.info("parsed: " + segments.size() + " segments");
return segments;
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例3: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public NonPrivateFieldsFieldDetectionPolicyModel parse(JsonParser jsonParser) throws IOException {
NonPrivateFieldsFieldDetectionPolicyModel instance = new NonPrivateFieldsFieldDetectionPolicyModel();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:NonPrivateFieldsFieldDetectionPolicyModel$$JsonObjectMapper.java
示例4: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public NodeRef deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException
{
JsonToken curr = jp.getCurrentToken();
if (curr == JsonToken.VALUE_STRING)
{
String nodeRefString = jp.getText();
NodeRef nodeRef = getNodeRef(nodeRefString);
return nodeRef;
}
else
{
throw new IOException("Unable to deserialize nodeRef: " + curr.asString());
}
}
示例5: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public NestedCollectionModel parse(JsonParser jsonParser) throws IOException {
NestedCollectionModel instance = new NestedCollectionModel();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
示例6: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public LowerCaseNamingPolicyModel parse(JsonParser jsonParser) throws IOException {
LowerCaseNamingPolicyModel instance = new LowerCaseNamingPolicyModel();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
示例7: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public BaseModel<T> parse(JsonParser jsonParser) throws IOException {
BaseModel<T> instance = new BaseModel<T>();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
示例8: handleMissingInstantiator
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Object handleMissingInstantiator(DeserializationContext ctxt, Class<?> instClass, ValueInstantiator valueInsta,
JsonParser p, String msg) throws IOException {
/* FIXME: For some reason Jackson can't find the {@link Canvas(String)} constructor, so we do it ourselves:
* 1. Check if the deserializer bails out on a JSON string
* 2. Find a String-constructor on the target class
* 3. Build the object */
if (p.getCurrentToken() == JsonToken.VALUE_STRING) {
}
try {
// Special case for empty strings in collection fields.
if (p.getValueAsString().isEmpty() && Collection.class.isAssignableFrom(instClass)) {
return instClass.getConstructor().newInstance();
} else {
Constructor<?> constructor = instClass.getConstructor(String.class);
return constructor.newInstance(p.getValueAsString());
}
} catch (Exception e) {
// Fall through
}
return super.handleMissingInstantiator(ctxt, instClass, valueInsta, p, msg);
}
示例9: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public SimpleGenericModelWithExtends<T> parse(JsonParser jsonParser) throws IOException {
SimpleGenericModelWithExtends<T> instance = new SimpleGenericModelWithExtends<T>();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jsonParser.skipChildren();
return null;
}
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.getCurrentName();
jsonParser.nextToken();
parseField(instance, fieldName, jsonParser);
jsonParser.skipChildren();
}
return instance;
}
示例10: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Boolean parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getBooleanValue();
}
}
示例11: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Integer parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getIntValue();
}
}
示例12: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Profile deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
if (p.getCurrentToken() == JsonToken.VALUE_STRING) {
if (isImageApiProfile(p.getValueAsString())) {
return new ImageApiProfile(p.getValueAsString());
} else {
return new Profile(URI.create(p.getValueAsString()));
}
} else if (p.getCurrentToken() == JsonToken.START_OBJECT) {
return p.getCodec().readValue(p, ImageApiProfile.class);
} else {
return (Profile) defaultDeserializer.deserialize(p, ctxt);
}
}
示例13: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public UUID deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
JsonToken token = parser.getCurrentToken();
if (token == JsonToken.VALUE_STRING) {
String string = parser.getValueAsString().trim();
return Url62.decode(string);
}
throw new IllegalStateException("This is not friendly id");
}
示例14: parseArray
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Object[] parseArray(JsonParser parser, DeserializationContext context) throws IOException,
JsonProcessingException
{
boolean started = false;
final List<Object> values = Lists.newArrayList();
while( parser.hasCurrentToken() )
{
final JsonToken currentToken = parser.getCurrentToken();
switch( currentToken )
{
case START_ARRAY:
if( started )
{
values.add(parseArray(parser, context));
}
started = true;
break;
case END_ARRAY:
if( !started )
{
throw context.mappingException("End array encountered without start " + where(parser, context));
}
return values.toArray();
case NOT_AVAILABLE:
break;
default:
if( !started )
{
throw context.mappingException("Value encountered without array start "
+ where(parser, context));
}
values.add(parse(parser, context));
}
parser.nextToken();
}
throw context.mappingException("No end array found " + where(parser, context));
}
示例15: getEntryNameFromJson
import com.fasterxml.jackson.core.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.createParser(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 == StaticFlowEntryPusher.COLUMN_NAME)
return jp.getText();
}
return null;
}