pypyr.steps.fetchjson permalink

load & parse json permalink

Loads a json file into the pypyr context.

This step requires the following key in the pypyr context:

- name: pypyr.steps.fetchjson
  comment: fetch json from path
  in:
    fetchJson:
      path: ./path.json # required. path to file on disk. can be relative.
      key: destinationKey # optional. write json to this context key.

If you do not specify key, json writes directly to context root.

If you do not want to specify a key, you can also use the streamlined format:

- name: pypyr.steps.fetchjson
  comment: simplified input with only path
  in:
    fetchJson: ./path.json # required. path to file on disk. can be relative.

All inputs support substitutions.

See some worked examples of fetchjson.

json structure permalink

pypyr will merge the Json parsed from the file into the pypyr context. This will overwrite existing values if the same keys already exist in context.

I.e if file json has {'eggs' : 'boiled'}, but context {'eggs': 'fried'} already exists, after fetchjson the key context['eggs'] will be ‘boiled’.

If you do not specify key, the json must not be an Array [] at the root level, but rather an Object {}.

see also

last updated on .