Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 659 Bytes

File metadata and controls

36 lines (27 loc) · 659 Bytes

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}}