1
1
mirror of https://github.com/wader/fq.git synced 2024-11-28 03:02:55 +03:00
fq/format/bson/bson.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

19 lines
381 B
Plaintext

def _bson_torepr:
def _f:
( if .type == null or .type == "array" then
( .value.elements
| map(_f)
)
elif .type == "document" then
( .value.elements
| map({key: .name, value: _f})
| from_entries
)
elif .type == "boolean" then .value != 0
else .value | tovalue
end
);
( {type: "document", value: .}
| _f
);