1
1
mirror of https://github.com/wader/fq.git synced 2024-11-24 11:16:09 +03:00
fq/format/msgpack/msgpack.jq
Mattias Wadman 149cb3f45a interp: Add torepr/0 that converts decode value into what it reptresents
Ex: fq -d msgpack torepr file.msgpack
Willoutput the JSON representation of the msgpack

Make per format *_torepr functions internal
2022-01-12 17:33:58 +01:00

14 lines
438 B
Plaintext

def _msgpack_torepr:
def _f:
( if .type | . == "fixmap" or . == "map16" or . == "map32" then
( .pairs
| map({key: (.key | _f), value: (.value | _f)})
| from_entries
)
elif .type | . == "fixarray" or . == "array16" or . == "array32" then .elements | map(_f)
elif .type | . == "bin8" or . == "bin16" or . == "bin32" then .value | tostring
else .value | tovalue
end
);
_f;