1
1
mirror of https://github.com/wader/fq.git synced 2024-12-22 04:41:36 +03:00
fq/format/bson/bson.jq
Mattias Wadman 628f0f403d bson: Add decoder
Only supports basic types for now
2022-01-06 00:51:37 +01:00

19 lines
390 B
Plaintext

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