1
1
mirror of https://github.com/wader/fq.git synced 2024-11-29 23:27:12 +03:00
fq/format/msgpack/msgpack.jq

11 lines
419 B
Plaintext
Raw Normal View History

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