Skip to content

Json Reader

This variable reads 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

  • repeat bool (optional) - whether values should be reused, e.g. when reaching the end it should start from the beginning again (default: False)
  • random bool (optional) - if rows should be selected by random, instead of sequential from first to last (default: 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"
}

etc.

atomicjsonreader__base_type__

def atomicjsonreader__base_type__(value: str) -> str

[view_source]

Validate values that AtomicJsonReader can be initialized with.