mongodb print json without whitespace i.e. unpretty json

后端 未结 6 1132
礼貌的吻别
礼貌的吻别 2020-12-30 19:52

I\'m using mongodb 2.2.0 and am trying to print json in a single line as opposed to \"pretty\" printing using printjson() or find().pretty(). i.e.

6条回答
  •  轮回少年
    2020-12-30 20:27

    if each item has {} brackets and there are no others then split it up on the brackets using a regular expression.

    This would split it up into {..} {..} items. But if there are nested {} it would not work.

    var res = s.match(/\{(.|\s)*?\}/g);
    if(res) for(var x=0;x

提交回复
热议问题