Force mongodb to output strict JSON -
i want consume raw output of mongodb commands in other programs speak json. when run commands in mongo shell, represent extended json, fields in "shell mode", special fields numberlong , date, , timestamp. see references in documentation "strict mode", see no way turn on shell, or way run commands db.serverstatus() in things do output strict json, mongodump. how can force mongo output standards-compliant json?
there several other questions on topic, don't find of answers particularly satisfactory.
the mongodb shell speaks javascript, answer simple: use json.stringify(). if command db.serverstatus(), can this:
json.stringify(db.serverstatus()) this won't output proper "strict mode" representation of each of fields ({ "floatapprox": <number> } instead of { "$numberlong": "<number>" }), if care getting standards-compliant json out, this'll trick.
Comments
Post a Comment