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


Java JsonParser.getValueAsInt方法代码示例

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


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

示例1: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(NonPrivateFieldsFieldDetectionPolicyModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("annotated_string".equals(fieldName)) {
        instance.annotatedString = jsonParser.getValueAsString(null);
    } else if ("intToIgnoreForSerialization".equals(fieldName)){
        instance.intToIgnoreForSerialization = jsonParser.getValueAsInt();
    } else if ("nonAnnotatedList".equals(fieldName)){
        if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
            ArrayList<String> collection1 = new ArrayList<String>();
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                String value1;
                value1 = jsonParser.getValueAsString(null);
                collection1.add(value1);
            }
            instance.nonAnnotatedList = collection1;
        } else {
            instance.nonAnnotatedList = null;
        }
    } else if ("nonAnnotatedString".equals(fieldName)){
        instance.nonAnnotatedString = jsonParser.getValueAsString(null);
    } else if ("staticIntToInclude".equals(fieldName)){
        instance.staticIntToInclude = jsonParser.getValueAsInt();
    } else if ("transientIntToInclude".equals(fieldName)){
        instance.transientIntToInclude = jsonParser.getValueAsInt();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:NonPrivateFieldsFieldDetectionPolicyModel$$JsonObjectMapper.java

示例2: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(SimpleGenericModel<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
  if ("date".equals(fieldName)) {
    instance.date = getjava_util_Date_type_converter().parse(jsonParser);
  } else if ("string".equals(fieldName)) {
    instance.string = jsonParser.getValueAsString(null);
  } else if ("test_double".equals(fieldName)) {
    instance.testDouble = jsonParser.getValueAsDouble();
  } else if ("test_double_obj".equals(fieldName)) {
    instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
  } else if ("test_float".equals(fieldName)) {
    instance.testFloat = (float)jsonParser.getValueAsDouble();
  } else if ("test_float_obj".equals(fieldName)) {
    instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
  } else if ("test_int".equals(fieldName)) {
    instance.testInt = jsonParser.getValueAsInt();
  } else if ("test_int_obj".equals(fieldName)) {
    instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
  } else if ("test_long".equals(fieldName)) {
    instance.testLong = jsonParser.getValueAsLong();
  } else if ("test_long_obj".equals(fieldName)) {
    instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
  } else if ("test_string".equals(fieldName)) {
    instance.testString = jsonParser.getValueAsString(null);
  } else if ("test_t".equals(fieldName)) {
    instance.testT = m84ClassJsonMapper.parse(jsonParser);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SimpleGenericModel$$JsonObjectMapper.java

示例3: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(NonPrivateFieldsAndAccessorsFieldDetectionPolicyModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("annotated_string".equals(fieldName)) {
        instance.annotatedString = jsonParser.getValueAsString(null);
    } else if ("intToIgnoreForSerialization".equals(fieldName)){
        instance.intToIgnoreForSerialization = jsonParser.getValueAsInt();
    } else if ("nonAnnotatedList".equals(fieldName)){
        if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
            ArrayList<String> collection1 = new ArrayList<String>();
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                String value1;
                value1 = jsonParser.getValueAsString(null);
                collection1.add(value1);
            }
            instance.nonAnnotatedList = collection1;
        } else {
            instance.nonAnnotatedList = null;
        }
    } else if ("nonAnnotatedPrivateInt".equals(fieldName)){
        instance.setNonAnnotatedPrivateInt(jsonParser.getValueAsInt());
    } else if ("nonAnnotatedString".equals(fieldName)){
        instance.nonAnnotatedString = jsonParser.getValueAsString(null);
    } else if ("privateStaticIntToInclude".equals(fieldName)){
        instance.setPrivateStaticIntToInclude(jsonParser.getValueAsInt());
    } else if ("privateTransientIntToInclude".equals(fieldName)){
        instance.setPrivateTransientIntToInclude(jsonParser.getValueAsInt());
    } else if ("staticIntToInclude".equals(fieldName)){
        instance.staticIntToInclude = jsonParser.getValueAsInt();
    } else if ("transientIntToInclude".equals(fieldName)){
        instance.transientIntToInclude = jsonParser.getValueAsInt();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:NonPrivateFieldsAndAccessorsFieldDetectionPolicyModel$$JsonObjectMapper.java

示例4: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(MultipleFieldNamesModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("possible_double_name_1".equals(fieldName) || "possible_double_name_2".equals(fieldName)) {
        instance.testDouble = jsonParser.getValueAsDouble();
    } else if ("possible_float_name_1".equals(fieldName) || "possible_float_name_2".equals(fieldName)){
        instance.testFloat = (float)jsonParser.getValueAsDouble();
    } else if ("possible_int_name_1".equals(fieldName) || "possible_int_name_2".equals(fieldName)){
        instance.testInt = jsonParser.getValueAsInt();
    } else if ("possible_long_name_1".equals(fieldName) || "possible_long_name_2".equals(fieldName)){
        instance.testLong = jsonParser.getValueAsLong();
    } else if ("possible_string_name_1".equals(fieldName) || "possible_string_name_2".equals(fieldName)){
        instance.testString = jsonParser.getValueAsString(null);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:MultipleFieldNamesModel$$JsonObjectMapper.java

示例5: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(SimpleGenericModelWithExtends<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
  if ("date".equals(fieldName)) {
    instance.date = getjava_util_Date_type_converter().parse(jsonParser);
  } else if ("string".equals(fieldName)) {
    instance.string = jsonParser.getValueAsString(null);
  } else if ("test_double".equals(fieldName)) {
    instance.testDouble = jsonParser.getValueAsDouble();
  } else if ("test_double_obj".equals(fieldName)) {
    instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
  } else if ("test_float".equals(fieldName)) {
    instance.testFloat = (float)jsonParser.getValueAsDouble();
  } else if ("test_float_obj".equals(fieldName)) {
    instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
  } else if ("test_int".equals(fieldName)) {
    instance.testInt = jsonParser.getValueAsInt();
  } else if ("test_int_obj".equals(fieldName)) {
    instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
  } else if ("test_long".equals(fieldName)) {
    instance.testLong = jsonParser.getValueAsLong();
  } else if ("test_long_obj".equals(fieldName)) {
    instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
  } else if ("test_string".equals(fieldName)) {
    instance.testString = jsonParser.getValueAsString(null);
  } else if ("test_t".equals(fieldName)) {
    instance.testT = m84ClassJsonMapper.parse(jsonParser);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SimpleGenericModelWithExtends$$JsonObjectMapper.java

示例6: handleUnknownProperty

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser p,
                                     final JsonDeserializer<?> deserializer,
                                     final Object beanOrClass,
                                     final String propertyName) throws IOException {
    boolean handled = false;
    if (beanOrClass instanceof CachingPrincipalAttributesRepository) {
        final CachingPrincipalAttributesRepository repo = CachingPrincipalAttributesRepository.class.cast(beanOrClass);
        switch (propertyName) {
            case "duration":
                p.nextToken();
                p.nextToken();
                p.nextToken();
                p.nextToken();
                p.nextToken();
                p.nextToken();
                final String timeUnit = p.getText();
                p.nextToken();
                p.nextToken();
                p.nextToken();
                final int expiration = p.getValueAsInt();

                repo.setTimeUnit(timeUnit);
                repo.setExpiration(expiration);

                LOGGER.warn("CAS has converted legacy JSON property [{}] for type [{}]. It parsed 'expiration' value [{}] with time unit of [{}]."
                                + "It is STRONGLY recommended that you review the configuration and upgrade the legacy syntax.",
                        propertyName, beanOrClass.getClass().getName(), expiration, timeUnit);

                handled = true;
                break;
            default:
                break;
        }
    }

    return handled;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:39,代码来源:JasigRegisteredServiceDeserializationProblemHandler.java

示例7: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(ParentModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("parentTestInt".equals(fieldName)) {
        instance.parentTestInt = jsonParser.getValueAsInt();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ParentModel$$JsonObjectMapper.java

示例8: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(AbstractParentModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("parentTestInt".equals(fieldName)) {
        instance.parentTestInt = jsonParser.getValueAsInt();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:AbstractParentModel$$JsonObjectMapper.java

示例9: parseFieldName

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private static void parseFieldName(JsonParser jsonParser, DeserializationContext deserializationContext,
                                   JsonParsingContext parsingContext) throws IOException {
    switch (jsonParser.getCurrentName()) {
        case NodeInfoJsonSerializer.ID:
            jsonParser.nextToken();
            parsingContext.id = jsonParser.getValueAsString();
            break;

        case NodeInfoJsonSerializer.NAME:
            jsonParser.nextToken();
            parsingContext.name = jsonParser.getValueAsString();
            break;

        case NodeInfoJsonSerializer.PSEUDO_CLASS:
            jsonParser.nextToken();
            parsingContext.pseudoClass = jsonParser.getValueAsString();
            break;

        case NodeInfoJsonSerializer.DESCRIPTION:
            jsonParser.nextToken();
            parsingContext.description = jsonParser.getValueAsString();
            break;

        case NodeInfoJsonSerializer.CREATION_TIME:
            jsonParser.nextToken();
            parsingContext.creationTime = jsonParser.getValueAsLong();
            break;

        case NodeInfoJsonSerializer.MODIFICATION_TIME:
            jsonParser.nextToken();
            parsingContext.modificationTime = jsonParser.getValueAsLong();
            break;

        case NodeInfoJsonSerializer.VERSION:
            jsonParser.nextToken();
            parsingContext.version = jsonParser.getValueAsInt();
            break;

        case NodeInfoJsonSerializer.METADATA:
            jsonParser.nextToken();
            parsingContext.metadata = new NodeGenericMetadataJsonDeserializer().deserialize(jsonParser, deserializationContext);
            break;

        default:
            throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());

    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:49,代码来源:NodeInfoJsonDeserializer.java

示例10: parse

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
	final JsonToken currentToken = parser.getCurrentToken();
	switch( currentToken )
	{
		case START_OBJECT:
			final Map<String, Object> oe = new MapDeserialiser().deserialize(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_OBJECT )
			{
				throw context.mappingException("Should be on end object " + where(parser, context));
			}
			return oe;

		case VALUE_FALSE:
		case VALUE_TRUE:
			return parser.getValueAsBoolean();

		case VALUE_NUMBER_INT:
			return parser.getValueAsInt();

		case VALUE_NUMBER_FLOAT:
			return parser.getValueAsDouble();

		case VALUE_NULL:
			return "null";

		case VALUE_STRING:
			return "\"" + parser.getText() + "\"";

		case START_ARRAY:
			final Object[] ae = parseArray(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_ARRAY )
			{
				throw context.mappingException("Should be on end array " + where(parser, context));
			}
			return ae;

		case END_ARRAY:
		case END_OBJECT:
			// whoops
			throw context.mappingException("Unexpected end object/array " + where(parser, context));

		case FIELD_NAME:
		case NOT_AVAILABLE:
			throw context.mappingException("How? " + where(parser, context));

		default:
			throw context.mappingException("Unhandled token " + where(parser, context));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:51,代码来源:MapDeserialiser.java

示例11: parse

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
	final JsonToken currentToken = parser.getCurrentToken();
	switch( currentToken )
	{
		case START_OBJECT:
			final ObjectExpression oe = new ObjectExpressionDeserialiser().deserialize(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_OBJECT )
			{
				throw context.mappingException("Should be on end object " + where(parser, context));
			}
			return oe;

		case VALUE_FALSE:
		case VALUE_TRUE:
			return new PrimitiveValueExpression(parser.getValueAsBoolean());

		case VALUE_NUMBER_INT:
			return new PrimitiveValueExpression(parser.getValueAsInt());

		case VALUE_NUMBER_FLOAT:
			return new PrimitiveValueExpression(parser.getValueAsDouble());

		case VALUE_NULL:
			return new NullExpression();

		case VALUE_STRING:
			return new StringExpression(parser.getText());

		case START_ARRAY:
			final ArrayExpression ae = parseArray(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_ARRAY )
			{
				throw context.mappingException("Should be on end array " + where(parser, context));
			}
			return ae;

		case END_ARRAY:
		case END_OBJECT:
			// whoops
			throw context.mappingException("Unexpected end object/array " + where(parser, context));

		case FIELD_NAME:
		case NOT_AVAILABLE:
			throw context.mappingException("How? " + where(parser, context));

		default:
			throw context.mappingException("Unhandled token " + where(parser, context));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:51,代码来源:ObjectExpressionDeserialiser.java


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