当前位置: 首页>>代码示例>>Java>>正文


Java JsonParser.getCurrentToken方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SimpleGenericModel$$JsonObjectMapper.java

示例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);
       }
   }
 
开发者ID:graphium-project,项目名称:graphium,代码行数:27,代码来源:GenericJacksonSegmentInputFormat.java

示例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());
       }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:NodeRefDeserializer.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:NestedCollectionModel$$JsonObjectMapper.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:LowerCaseNamingPolicyModel$$JsonObjectMapper.java

示例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;
}
 
开发者ID:xuehuayous,项目名称:Hannibai,代码行数:19,代码来源:BaseModel$$JsonObjectMapper.java

示例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);
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:23,代码来源:ProblemHandler.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SimpleGenericModelWithExtends$$JsonObjectMapper.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:BooleanMapper.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:IntegerMapper.java

示例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);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:15,代码来源:ProfileDeserializer.java

示例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");
}
 
开发者ID:Devskiller,项目名称:friendly-id,代码行数:11,代码来源:FriendlyIdDeserializer.java

示例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));
}
 
开发者ID:equella,项目名称:Equella,代码行数:38,代码来源:MapDeserialiser.java

示例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;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:StaticFlowEntries.java


注:本文中的com.fasterxml.jackson.core.JsonParser.getCurrentToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。