Skip to content

JSON Reader

formatting...

Read a JSON file that contains a list of objects and provides a new object from the list each time it is accessed.

The JSON file must contain a list of JSON objects, and each object must have the same properties.

Format

Value is the path, relative to requests/, of an file ending with .json.

Arguments

Name Type Description Default
repeat bool whether values should be reused, e.g. when reaching the end it should start from the beginning again False
random bool if rows should be selected by random, instead of sequential from first to last False

Example

requests/example.json
[
  {
    "username": "bob1",
    "password": "some-password"
  },
  {
    "username": "alice1",
    "password": "some-other-password"
  },
  {
    "username": "bob2",
    "password": "password"
  }
]
And value for variable "AtomicJsonReader.example" is "example.json | random=False, repeat=True"

# Reference property by property
Then post request with name "authenticate" to endpoint "/api/v1/authenticate"
  """
  {
      "username": "{{ AtomicJsonReader.example.username }}",
      "password": "{{ AtomicJsonReader.example.password }}"
  }
  """

# Reference object
Then post request with name "authenticate" to endpoint "/api/v1/authenticate"
  """
  {{ AtomicJsonReader.example }}
  """

First request the payload will be:

{
    "username": "bob1",
    "password": "some-password"
}

Second request:

{
    "username": "alice1",
    "password": "some-other-password"
}