Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在node.js中将bson转换为json?_Json_Node.js_Bson - Fatal编程技术网

如何在node.js中将bson转换为json?

如何在node.js中将bson转换为json?,json,node.js,bson,Json,Node.js,Bson,如何在node.js中将bson转换为json? 我正在检查两个不同obj之间的差异,这显示了一个错误,因为它需要JSON。(来自Mongodb的数据fatch) 我正在使用下面的链接快速json补丁,但它不起作用 下面的作业1数据:我想比较作业1和作业2 [ { name: 'Tape', cost: 10, datetime: 2016-12-29T14:28:06.846Z, update_by: '', _id: 5

如何在node.js中将bson转换为json?

我正在检查两个不同obj之间的差异,这显示了一个错误,因为它需要JSON。(来自Mongodb的数据fatch)

我正在使用下面的链接快速json补丁,但它不起作用

下面的作业1数据:我想比较作业1和作业2

  [ { name: 'Tape',
        cost: 10,
        datetime: 2016-12-29T14:28:06.846Z,
        update_by: '',
        _id: 58651d762cd7d2f00cc2de26,
        image_path: null },  

     { name: 'Wire',
        cost: 100,
        datetime: 2016-12-29T14:28:06.845Z,
        update_by: '',
        _id: 58651d762cd7d2f00cc2de24,
        image_path: null } ]
工作2

[ { image_path: null,
    _id: '58651d762cd7d2f00cc2de26',
    update_by: '',
    datetime: '2016-12-29T14:28:06.846Z',
    cost: 10,
    name: 'Tape',
    id: '58651d762cd7d2f00cc2de26' },

  { image_path: null,
    _id: '58651d762cd7d2f00cc2de24',
    update_by: '',
    datetime: '2016-12-29T14:28:06.845Z',
    cost: 100,
    name: 'Wire',
    id: '58651d762cd7d2f00cc2de24' } ]

job
job2
在bson中?是的,亲爱的…一个是请求..另一个是来自mongodb的fatch数据
[ { image_path: null,
    _id: '58651d762cd7d2f00cc2de26',
    update_by: '',
    datetime: '2016-12-29T14:28:06.846Z',
    cost: 10,
    name: 'Tape',
    id: '58651d762cd7d2f00cc2de26' },

  { image_path: null,
    _id: '58651d762cd7d2f00cc2de24',
    update_by: '',
    datetime: '2016-12-29T14:28:06.845Z',
    cost: 100,
    name: 'Wire',
    id: '58651d762cd7d2f00cc2de24' } ]