Person edit
JQ is short for Jamshed Qureshi.Software edit
Description
jq
- your JSON arrays to be converted to dicts with integer keys (e.g., ["a", "b", "c"] to {0 a 1 b 2 c} rather than {a b c});
- a JSON parser in Jim Tcl faster than the recursive one from jimhttp.
Download command
Download the module with wiki-reaper: wiki-reaper 11630 0 17 > jq-0.4.0.tm.Module source code
# jq-0.4.0.tm # To use this module you need jq version 1.5rc1 or later installed. namespace eval jq { proc jq {filter data {options {-r}}} { exec jq {*}$options $filter << $data } proc json2dict {data} { jq { def totcl: if type == "array" then # Convert array to object with keys 0, 1, 2... and process # it as object. [range(0;length) as $i | {key: $i | tostring, value: .[$i]}] | from_entries | totcl elif type == "object" then . | to_entries | map("{\(.key)} {\(.value | totcl)}") | join(" ") else tostring | gsub("{"; "\\{") | gsub("}"; "\\}") end; . | totcl } $data } }
dbohdan: I hope Jamshed doesn't mind me using this page. If he objects I will create a separate page for jq the program.