Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.24 KB

File metadata and controls

52 lines (37 loc) · 1.24 KB

expandjson

Expand JSON strings embedded in record fields into actual JSON values.

Synopsis

recs expandjson [options] [files...]

Description

Expand JSON strings embedded in record fields into actual JSON values. When a field contains a string that is valid JSON (object, array, etc.), this operation parses it and replaces the string with the parsed structure. With no --key options, all top-level string fields that look like JSON are expanded.

Options

Flag Description
--key / -k <key> Key containing a JSON string to expand. May be a keyspec. May be specified multiple times for multiple keys.
--recursive / -r Recursively expand JSON strings found in nested values after initial expansion.

Examples

Expand a metadata field containing a JSON string

recs expandjson --key metadata

Input:

{"name":"alice","metadata":"{\"role\":\"admin\",\"level\":3}"}

Output:

{"name":"alice","metadata":{"role":"admin","level":3}}

Recursively expand nested JSON strings

recs expandjson -r --key payload

Expand all JSON-like string fields automatically

recs expandjson

See Also