Skip to main content
Version: v1.9.0

parse_zson

Function

parse_zson parse ZSON or JSON text into a Zed value

Synopsis

parse_zson(s: string) -> any

Description

The parse_zson function parses the s argument that must be in the form of ZSON or JSON into a Zed value of any type. This is analogous to JavaScript's JSON.parse() function.

Examples

Parse ZSON text

echo '{foo:"{a:\"1\",b:2}"}' | zq -z 'foo := parse_zson(foo)' -

=>

{foo:{a:"1",b:2}}

Parse JSON text

echo '{"foo": "{\"a\": \"1\", \"b\": 2}"}' | zq -z 'foo := parse_zson(foo)' -

=>

{foo:{a:"1",b:2}}