想要我的数据以json格式发布请求

时间:2018-02-03 20:59:03

标签: json mongodb

我有这种状态的数据

{prodName:"parle",prodDesc:"The fresh milk biscuits for children",prodPrice:"30",prodManufacturer:"biscuits"}

我在发布请求时想要这种形式的数据,并且我试图从

获取此值
{"prodName":"parle","prodDesc":"The fresh milk biscuits for children","prodPrice":30,"prodManufacturer":"biscuits"}

请任何人都可以帮助无法在mongo db中推送数据

1 个答案:

答案 0 :(得分:0)

您需要致电JSON.stringify以便用双引号括起来

db.state.find({},{_id:0})
    .forEach(function(d){
         print(JSON.stringify(d));
    }
)

输出

> db.state.find({},{_id:0}).forEach(function(d){ print ( JSON.stringify(d))})
{"prodName":"parle","prodDesc":"The fresh milk biscuits for children","prodPrice":"30","prodManufacturer":"biscuits"}
>