1
1
mirror of https://github.com/wader/fq.git synced 2024-11-27 14:14:58 +03:00
fq/format/msgpack/msgpack.jq
2022-03-08 17:09:48 +01:00

11 lines
419 B
Plaintext

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;