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


Java JsonParser.getCurrentToken方法代码示例

本文整理汇总了Java中org.codehaus.jackson.JsonParser.getCurrentToken方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getCurrentToken方法的具体用法?Java JsonParser.getCurrentToken怎么用?Java JsonParser.getCurrentToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.JsonParser的用法示例。


在下文中一共展示了JsonParser.getCurrentToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BackportedJacksonMappingIterator

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) {
    _type = type;
    _parser = jp;
    _context = ctxt;
    _deserializer = (JsonDeserializer<T>) deser;

    /* One more thing: if we are at START_ARRAY (but NOT root-level
     * one!), advance to next token (to allow matching END_ARRAY)
     */
    if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) {
        JsonStreamContext sc = jp.getParsingContext();
        // safest way to skip current token is to clear it (so we'll advance soon)
        if (!sc.inRoot()) {
            jp.clearCurrentToken();
        }
    }
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:19,代码来源:BackportedJacksonMappingIterator.java

示例2: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@Override
public Instant deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException
{
    final JsonToken jsonToken = parser.getCurrentToken();

    if (jsonToken == JsonToken.VALUE_NUMBER_INT)
    {
        return new Instant(parser.getLongValue());
    }
    else if (jsonToken == JsonToken.VALUE_STRING)
    {
        final String str = parser.getText().trim();
        if (str.length() == 0)
        {
            return null;
        }
        final DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser();
        final DateTime dateTime = formatter.parseDateTime(str);

        return new Instant(dateTime.getMillis());
    }

    throw ctxt.mappingException(Instant.class);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:26,代码来源:InstantDeserializer.java

示例3: _parseDate

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
protected java.util.Date _parseDate(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  try
  {
    if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
      return new java.util.Date(paramJsonParser.getLongValue());
    if (localJsonToken == JsonToken.VALUE_STRING)
    {
      String str = paramJsonParser.getText().trim();
      if (str.length() == 0)
        return null;
      return paramDeserializationContext.parseDate(str);
    }
    throw paramDeserializationContext.mappingException(this._valueClass);
  }
  catch (IllegalArgumentException localIllegalArgumentException)
  {
  }
  throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid representation (error: " + localIllegalArgumentException.getMessage() + ")");
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:StdDeserializer.java

示例4: deserialize

import org.codehaus.jackson.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,项目名称:community-edition-old,代码行数:18,代码来源:NodeRefDeserializer.java

示例5: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
public String deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_STRING)
    return paramJsonParser.getText();
  if (localJsonToken == JsonToken.VALUE_EMBEDDED_OBJECT)
  {
    Object localObject = paramJsonParser.getEmbeddedObject();
    if (localObject == null)
      return null;
    if ((localObject instanceof byte[]))
      return Base64Variants.getDefaultVariant().encode((byte[])(byte[])localObject, false);
    return localObject.toString();
  }
  if (localJsonToken.isScalarValue())
    return paramJsonParser.getText();
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:20,代码来源:StdDeserializer.java

示例6: handleNonArray

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
  throws IOException, JsonProcessingException
{
  if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
    throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  Object localObject;
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
    localObject = null;
  while (true)
  {
    paramCollection.add(localObject);
    return paramCollection;
    if (localTypeDeserializer == null)
    {
      localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
      continue;
    }
    localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:CollectionDeserializer.java

示例7: deserializeObject

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
protected final ObjectNode deserializeObject(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  ObjectNode localObjectNode = paramDeserializationContext.getNodeFactory().objectNode();
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.START_OBJECT);
  for (localJsonToken = paramJsonParser.nextToken(); localJsonToken == JsonToken.FIELD_NAME; localJsonToken = paramJsonParser.nextToken())
  {
    String str = paramJsonParser.getCurrentName();
    paramJsonParser.nextToken();
    JsonNode localJsonNode1 = deserializeAny(paramJsonParser, paramDeserializationContext);
    JsonNode localJsonNode2 = localObjectNode.put(str, localJsonNode1);
    if (localJsonNode2 == null)
      continue;
    _handleDuplicateField(str, localObjectNode, localJsonNode2, localJsonNode1);
  }
  return localObjectNode;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:BaseNodeDeserializer.java

示例8: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
public Map<Object, Object> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if ((localJsonToken != JsonToken.START_OBJECT) && (localJsonToken != JsonToken.FIELD_NAME) && (localJsonToken != JsonToken.END_OBJECT))
    throw paramDeserializationContext.mappingException(getMapClass());
  if (this._propertyBasedCreator != null)
    return _deserializeUsingCreator(paramJsonParser, paramDeserializationContext);
  if (this._defaultCtor == null)
    throw paramDeserializationContext.instantiationException(getMapClass(), "No default constructor found");
  try
  {
    Map localMap = (Map)this._defaultCtor.newInstance(new Object[0]);
    _readAndBind(paramJsonParser, paramDeserializationContext, localMap);
    return localMap;
  }
  catch (Exception localException)
  {
  }
  throw paramDeserializationContext.instantiationException(getMapClass(), localException);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:MapDeserializer.java

示例9: getVaueAsTree

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
private static List<JsonElement> getVaueAsTree(JsonParser in) throws IOException {
	int level = 0;
	List<JsonElement> result = new ArrayList<JsonElement>();
	do {
		JsonToken t = in.getCurrentToken();
		switch (t) {
			case START_OBJECT:
			case START_ARRAY:
				level++;
				result.add(new JsonElement(t));
				break;
			case END_OBJECT:
			case END_ARRAY:
				level--;
				result.add(new JsonElement(t));
				break;
			case FIELD_NAME:
			case VALUE_STRING:
			case VALUE_NUMBER_INT:
			case VALUE_NUMBER_FLOAT:
			case VALUE_TRUE:
			case VALUE_FALSE:
			case VALUE_NULL:
				result.add(new JsonElement(t, in.getText()));
				break;
		}
		in.nextToken();
	} while (level != 0);
	result.add(new JsonElement(null));
	return result;
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:32,代码来源:ExtendedJsonDecoder.java

示例10: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@Override
public Duration deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws JsonParseException, IOException
{
    final JsonToken jsonToken = parser.getCurrentToken();

    if (jsonToken == JsonToken.VALUE_NUMBER_INT)
    {
        return new Duration(parser.getLongValue());
    }
    else if (jsonToken == JsonToken.VALUE_STRING)
    {
        final String str = parser.getText().trim();
        if (str.length() == 0)
        {
            return null;
        }
        final PeriodFormatter formatter = ISOPeriodFormat.standard();
        return formatter.parsePeriod(str).toStandardDuration();
    }

    throw ctxt.mappingException(Duration.class);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:24,代码来源:DurationDeserializer.java

示例11: jsonToHostDefinition

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createJsonParser(json);
    } 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;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }
    
    jp.close();
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:39,代码来源:HostResource.java

示例12: getEntryNameFromJson

import org.codehaus.jackson.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.createJsonParser(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 == "name")
            return jp.getText();
    }
    
    return null;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:38,代码来源:StaticFlowEntries.java

示例13: jsonExtractSubnetMask

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(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 == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:41,代码来源:FirewallResource.java

示例14: getVaueAsTree

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@SuppressWarnings("incomplete-switch")
private static List<JsonElement> getVaueAsTree(JsonParser in) throws IOException {
  int level = 0;
  List<JsonElement> result = new ArrayList<JsonElement>();
  do {
    JsonToken t = in.getCurrentToken();
    switch (t) {
    case START_OBJECT:
    case START_ARRAY:
      level++;
      result.add(new JsonElement(t));
      break;
    case END_OBJECT:
    case END_ARRAY:
      level--;
      result.add(new JsonElement(t));
      break;
    case FIELD_NAME:
    case VALUE_STRING:
    case VALUE_NUMBER_INT:
    case VALUE_NUMBER_FLOAT:
    case VALUE_TRUE:
    case VALUE_FALSE:
    case VALUE_NULL:
      result.add(new JsonElement(t, in.getText()));
      break;
    }
    in.nextToken();
  } while (level != 0);
  result.add(new JsonElement(null));
  return result;
}
 
开发者ID:openaire,项目名称:iis,代码行数:33,代码来源:HackedJsonDecoder.java

示例15: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
public final Object deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
  {
    if (this._nullProvider == null)
      return null;
    return this._nullProvider.nullValue(paramDeserializationContext);
  }
  if (this._valueTypeDeserializer != null)
    return this._valueDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, this._valueTypeDeserializer);
  return this._valueDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:14,代码来源:SettableBeanProperty.java


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