Package io.restassured.path.json.config
Class JsonPathConfig
java.lang.Object
io.restassured.path.json.config.JsonPathConfig
Allows you to configure how JsonPath will handle JSON numbers and object mappers. By default JsonPath and body expectations
in REST Assured will return floats for numbers that are less than or equal to
Float.MAX_VALUE or doubles
for larger numbers. In Groovy 1.8.5 they changed so that all numbers are now BigDecimals. If you prefer that
you can configure the JsonPathConfig.NumberReturnType to be JsonPathConfig.NumberReturnType.BIG_DECIMAL.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies what kind of numbers to return. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new JsonPathConfig that is configured to return floats and doubles and use the systems default charset for JSON data.JsonPathConfig(JsonPathConfig config) Create a new instance of a JsonPathConfig based on the properties in the supplied config.JsonPathConfig(JsonPathConfig.NumberReturnType numberReturnType) Create a new JsonPathConfig that returns JSON numbers as either Doubles and Floats or BigDecimalsJsonPathConfig(String defaultCharset) Create a new JsonPathConfig that uses thedefaultCharsetwhen deserializing JSON data. -
Method Summary
Modifier and TypeMethodDescriptionand()For syntactic sugar.charset()defaultObjectDeserializer(JsonPathObjectDeserializer defaultObjectDeserializer) Creates an json path configuration that uses the specified object de-serializer as default.defaultParserType(JsonParserType defaultParserType) Creates an json path configuration that uses the specified parser type as default.gsonObjectMapperFactory(GsonObjectMapperFactory gsonObjectMapperFactory) Specify a custom Gson object mapper factory.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanjackson1ObjectMapperFactory(Jackson1ObjectMapperFactory jackson1ObjectMapperFactory) Specify a custom Jackson 1.0 object mapper factory.jackson2ObjectMapperFactory(Jackson2ObjectMapperFactory jackson2ObjectMapperFactory) Specify a custom Jackson 1.0 object mapper factory.jsonbObjectMapperFactory(JsonbObjectMapperFactory jsonbObjectMapperFactory) Specify a custom JSON-B object mapper factory.static JsonPathConfignumberReturnType(JsonPathConfig.NumberReturnType numberReturnType) Specifies if JsonPath should use floats and doubles or BigDecimals to represent Json numbers.booleanwith()For syntactic sugar.
-
Constructor Details
-
JsonPathConfig
Create a new instance of a JsonPathConfig based on the properties in the supplied config.- Parameters:
config- The config to copy.
-
JsonPathConfig
public JsonPathConfig()Creates a new JsonPathConfig that is configured to return floats and doubles and use the systems default charset for JSON data. -
JsonPathConfig
Create a new JsonPathConfig that returns JSON numbers as either Doubles and Floats or BigDecimals -
JsonPathConfig
Create a new JsonPathConfig that uses thedefaultCharsetwhen deserializing JSON data.
-
-
Method Details
-
charset
- Returns:
- The charset to assume when parsing JSON data
-
charset
- Returns:
- A new JsonPathConfig instance with that assumes the supplied charset when parsing JSON documents.
-
numberReturnType
-
numberReturnType
Specifies if JsonPath should use floats and doubles or BigDecimals to represent Json numbers.- Parameters:
numberReturnType- The choice.- Returns:
- A new instance of JsonPathConfig with the given configuration
-
shouldRepresentJsonNumbersAsBigDecimal
public boolean shouldRepresentJsonNumbersAsBigDecimal() -
defaultParserType
-
hasDefaultParserType
public boolean hasDefaultParserType() -
hasCustomGsonObjectMapperFactory
public boolean hasCustomGsonObjectMapperFactory() -
hasCustomJackson10ObjectMapperFactory
public boolean hasCustomJackson10ObjectMapperFactory() -
hasCustomJackson30ObjectMapperFactory
public boolean hasCustomJackson30ObjectMapperFactory() -
hasCustomJackson20ObjectMapperFactory
public boolean hasCustomJackson20ObjectMapperFactory() -
hasCustomJohnzonObjectMapperFactory
public boolean hasCustomJohnzonObjectMapperFactory() -
hasCustomJsonbObjectMapperFactory
public boolean hasCustomJsonbObjectMapperFactory() -
defaultParserType
Creates an json path configuration that uses the specified parser type as default.- Parameters:
defaultParserType- The parser type to use. Ifnullthen classpath scanning will be used.
-
defaultDeserializer
-
hasDefaultDeserializer
public boolean hasDefaultDeserializer() -
defaultObjectDeserializer
public JsonPathConfig defaultObjectDeserializer(JsonPathObjectDeserializer defaultObjectDeserializer) Creates an json path configuration that uses the specified object de-serializer as default.- Parameters:
defaultObjectDeserializer- The object de-serializer to use. Ifnullthen classpath scanning will be used.
-
gsonObjectMapperFactory
-
gsonObjectMapperFactory
Specify a custom Gson object mapper factory.- Parameters:
gsonObjectMapperFactory- The object mapper factory
-
jackson1ObjectMapperFactory
-
jackson3ObjectMapperFactory
-
jackson1ObjectMapperFactory
public JsonPathConfig jackson1ObjectMapperFactory(Jackson1ObjectMapperFactory jackson1ObjectMapperFactory) Specify a custom Jackson 1.0 object mapper factory.- Parameters:
jackson1ObjectMapperFactory- The object mapper factory
-
jackson2ObjectMapperFactory
-
johnzonObjectMapperFactory
-
jackson2ObjectMapperFactory
public JsonPathConfig jackson2ObjectMapperFactory(Jackson2ObjectMapperFactory jackson2ObjectMapperFactory) Specify a custom Jackson 1.0 object mapper factory.- Parameters:
jackson2ObjectMapperFactory- The object mapper factory
-
jsonbObjectMapperFactory
-
jsonbObjectMapperFactory
Specify a custom JSON-B object mapper factory.- Parameters:
jsonbObjectMapperFactory- The object mapper factory
-
jsonPathConfig
- Returns:
- A static way to create a new JsonPathConfig instance without calling "new" explicitly. Mainly for syntactic sugar.
-
with
For syntactic sugar.- Returns:
- The same JsonPathConfig instance
-
and
For syntactic sugar.- Returns:
- The same JsonPathConfig instance
-