edit_json

Operation to edit json by merging data into existing json data.

Example

The following example adds/updates the test script in a package.json file:

examples/operations/edit_json.yml
steps:
    "Add test script to package.json":
        name: edit_json
        file_path: "examples/data/package.json"
        merge_data:
            scripts:
                test:
                    "jest"

Note that merge_data can specify arbitrarily nested data. This data will be merged with existing data, so other scripts defined in the file will be preserved.

Required context

file_path

Path to file relative to the current working directory.

merge_data

Dictionary of data that will be merged into existing data in json file.

Optional context

indent

default: 4

See also