1
1
mirror of https://github.com/wader/fq.git synced 2024-12-12 02:22:44 +03:00
fq/format/msgpack/msgpack.jq
Mattias Wadman 87b2c6c10c help,doc: Use markdown for format documentation again
Markdown is used as is in online documentation and in cli the markdown decoder
is used to decode and the some jq code massages it into something cli friendly.

Was just too much of a mess to have doc in jq.
2022-09-11 00:53:29 +02:00

12 lines
420 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;