nRF Util v7.1.0

Managing command output with JSON

Use JavaScript Object Notation (JSON) output for scripting and automation when building applications with nRF Util functionality.

nRF Util supports JSON output through the command line flag --json. This structures the data in a way that can be parsed by JSON parsers, available in many programming and scripting languages.

Data from nRF Util is communicated as a sequence of JSON messages. Each message is encoded as a single JSON object on a single line. All messages follow a common format:

{"type":[task_begin|task_end|task_progress|info|log]

"data": { ... }}

To view Python examples of using the JSON output from nrfutil device, run nrfutil device --help-extended.

Message types:

The task_* messages correspond to the progress bars and progress spinners rendered when not using the --json flag and are used to indicate that a long-running task is in progress.

The info message is used to convey general information. For example, nrfutil search --json uses the info message to convey the list of installable commands in JSON, and nrfutil device list --json uses the info message to list device information in JSON. To output the data payload only, add the flag --skip-overhead.

The main data payload in the JSON messages is contained within the `data` field. The task messages share some common fields across different contexts. The fields for the `info` messages vary from context to context. Investigate the fields manually when building applications on top of the JSON messages.

Standard semantic versioning guarantees are given for the JSON output formats across the different commands. Releases of the commands within the same major version number have backwards-compatible JSON messages.