Class JsonPathConfig

java.lang.Object
io.restassured.path.json.config.JsonPathConfig

public class JsonPathConfig extends Object
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.
  • Constructor Details

    • JsonPathConfig

      public JsonPathConfig(JsonPathConfig config)
      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

      public JsonPathConfig(JsonPathConfig.NumberReturnType numberReturnType)
      Create a new JsonPathConfig that returns JSON numbers as either Doubles and Floats or BigDecimals
    • JsonPathConfig

      public JsonPathConfig(String defaultCharset)
      Create a new JsonPathConfig that uses the defaultCharset when deserializing JSON data.
  • Method Details

    • charset

      public String charset()
      Returns:
      The charset to assume when parsing JSON data
    • charset

      public JsonPathConfig charset(String charset)
      Returns:
      A new JsonPathConfig instance with that assumes the supplied charset when parsing JSON documents.
    • numberReturnType

      public JsonPathConfig.NumberReturnType numberReturnType()
    • numberReturnType

      public JsonPathConfig numberReturnType(JsonPathConfig.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

      public JsonParserType 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

      public JsonPathConfig defaultParserType(JsonParserType defaultParserType)
      Creates an json path configuration that uses the specified parser type as default.
      Parameters:
      defaultParserType - The parser type to use. If null then classpath scanning will be used.
    • defaultDeserializer

      public JsonPathObjectDeserializer 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. If null then classpath scanning will be used.
    • gsonObjectMapperFactory

      public GsonObjectMapperFactory gsonObjectMapperFactory()
    • gsonObjectMapperFactory

      public JsonPathConfig gsonObjectMapperFactory(GsonObjectMapperFactory gsonObjectMapperFactory)
      Specify a custom Gson object mapper factory.
      Parameters:
      gsonObjectMapperFactory - The object mapper factory
    • jackson1ObjectMapperFactory

      public Jackson1ObjectMapperFactory jackson1ObjectMapperFactory()
    • jackson3ObjectMapperFactory

      public Jackson3ObjectMapperFactory jackson3ObjectMapperFactory()
    • jackson1ObjectMapperFactory

      public JsonPathConfig jackson1ObjectMapperFactory(Jackson1ObjectMapperFactory jackson1ObjectMapperFactory)
      Specify a custom Jackson 1.0 object mapper factory.
      Parameters:
      jackson1ObjectMapperFactory - The object mapper factory
    • jackson2ObjectMapperFactory

      public Jackson2ObjectMapperFactory jackson2ObjectMapperFactory()
    • johnzonObjectMapperFactory

      public JohnzonObjectMapperFactory johnzonObjectMapperFactory()
    • jackson2ObjectMapperFactory

      public JsonPathConfig jackson2ObjectMapperFactory(Jackson2ObjectMapperFactory jackson2ObjectMapperFactory)
      Specify a custom Jackson 1.0 object mapper factory.
      Parameters:
      jackson2ObjectMapperFactory - The object mapper factory
    • jsonbObjectMapperFactory

      public JsonbObjectMapperFactory jsonbObjectMapperFactory()
    • jsonbObjectMapperFactory

      public JsonPathConfig jsonbObjectMapperFactory(JsonbObjectMapperFactory jsonbObjectMapperFactory)
      Specify a custom JSON-B object mapper factory.
      Parameters:
      jsonbObjectMapperFactory - The object mapper factory
    • jsonPathConfig

      public static JsonPathConfig jsonPathConfig()
      Returns:
      A static way to create a new JsonPathConfig instance without calling "new" explicitly. Mainly for syntactic sugar.
    • with

      public JsonPathConfig with()
      For syntactic sugar.
      Returns:
      The same JsonPathConfig instance
    • and

      public JsonPathConfig and()
      For syntactic sugar.
      Returns:
      The same JsonPathConfig instance