Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:dpi:bras_bng:cli:json:start [2024/02/09 12:21] – elena.krasnobryzh | en:dpi:bras_bng:cli:json:start [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Output to json ====== | ||
- | {{indexmenu_n> | ||
- | All CLI commands can output data in JSON format. For this purpose, options are specified in the '' | ||
- | < | ||
- | fdpi_cli --json --strict < | ||
- | </ | ||
- | |||
- | JSON format allows processing CLI data by external scripts: filtering, making selections, etc. | ||
- | |||
- | We deliberately do not give a full description of the fields and their purpose for each CLI command, because we assume that the | ||
- | * the text output is quite informative; | ||
- | * comparing the textual output of the command with the JSON output gives a sufficiently complete picture of which field carries what information. | ||
- | |||
- | But we also try not to change field names or delete fields: whatever ugly field name was chosen by ignorance or misunderstanding, | ||
- | |||
- | We also reserve the right to change the textual format of CLI command output, so don't try to write the textual output of CLI commands in scripts - use JSON, we try to keep it more stable. | ||
- | |||
- | Many CLI commands that dump internal SSG databases output a dump with all internal fields and their values, so you should be warned about some peculiarities of JSON output. | ||
- | |||
- | SSG can "spit out" tens and hundreds of megabytes of data in response to a command, if it is a dump command of the '' | ||
- | |||
- | The CLI exhaust in JSON format looks like this (generic skeleton): | ||
- | < | ||
- | [ | ||
- | { | ||
- | # pack 1 | ||
- | }, | ||
- | { | ||
- | # pack 2 | ||
- | }, | ||
- | ... | ||
- | ] | ||
- | </ | ||
- | that is, it is an array of packs (objects). Each pack starts with '' | ||
- | < | ||
- | [ | ||
- | { | ||
- | " | ||
- | " | ||
- | }, | ||
- | # pack data - team dependent | ||
- | }, | ||
- | { | ||
- | " | ||
- | " | ||
- | }, | ||
- | # pack data - team dependent | ||
- | }, | ||
- | ... | ||
- | ] | ||
- | </ | ||
- | '' | ||
- | < | ||
- | [ | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | # If unsuccessful, | ||
- | ] | ||
- | </ | ||
- | Note that '' | ||
- | |||
- | When forming //each// bundle, an error may occur. If an error occurs, SSG will not attempt to execute the command further - any error is fatal. Therefore, if the n-th (last) bundle in the JSON output contains '' | ||
- | |||
- | Otherwise, it can be formulated as follows: the command was executed successfully if each object of the JSON response array has '' |