Assertible's JSON path assertion syntax allows you to get capture values from JSON response bodies using a simple & familiar syntax. Currently, the syntax allows you to traverse keys and array indexes; advanced syntax like array slicing and javascript expressions are not supported.

If you have a use-case that's not yet supported by this syntax Contact us and let us know!

  • key selection example

      {
        "id": 1,
        "firstName": "Chris",
        "foo": {
          "bar": "baz"
        }
      }
    • selector: .firstName

      result: "Chris"

    • selector: .foo.bar

      result: "baz"

  • key selection w/ dot in name

    { "name.with": 1 }
    • selector: ['name.with']

      result: 1

  • key selection w/ space in name

    { "name with": 1 }
    • selector: ['name with']

      result: 1

  • array index

      [
        {
          "id": 1,
          "firstName": "Chris",
        }
      ]
    • selector: [0].id

      result: 1

  • array length

      { "users": [1,2,3,4,5] }
    • selector: .users.length()

      result: 5

  • object "length"

      { "steps": {"step1": 1, "step2": 2} }
    • selector: .steps.length()

      result: 2

  • string "length"

      { "email": "my@email.com" }
    • selector: .email.length()

      result: 12


The JSON path .length() function can only be used at the end of a JSON path expression. For example, .foo[(@.length)] and .foo[(.length())] are not supported. .length() can only be used on JSON arrays and objects.

JSON Path wildcard syntax

Assertible's JSON Path syntax has limited support for wildcard syntax on JSON arrays and objects.

IMPORTANT Assertible's JSON Path syntax supports wildcards in the path. Only single node selections are valid using pure json path. If you need more advanced scripting capabilities, use the .jq() function.


  • array wildcard

      {
        "steps": [
          {
            "step_num": 1,
            "description": "Description"
          },
          {
            "step_num": 2,
            "description": "Description",
            "uncommon_field": "some data"
          }
        ]
      }
    • selector: .steps[].uncommon_field

      result: "some data"

    • selector: .steps[].step_num

      result: Invalid selection - selecting multiple nodes is not supported.

  • object wildcard

      {
        "foo": {
          "id": 1,
          "data": "baz"
        },
    
        "bar": {
          "id": 1,
          "data": "quux",
          "description": "hello world"
        },
    
        "steps": [
          {
            "step_num": 1,
            "description": "Description"
          },
          {
            "step_num": 2,
            "description": "Description",
            "uncommon_field": "some data"
          }
        ]
      }
    • selector: [*].description

      result: "hello world"

    • selector: [].description

      result: "hello world"

    • selector: [].data

      result: Invalid selection - selecting multiple nodes is not supported.


The easiest way to test and
monitor your web services

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free