我有数据,其中数据在字符串中有双引号,例如 - 位置:America" s。我们在json和csv都有数据。
对于数据集,我更改了来自Mongodb的样本数据集的餐馆数据中的一个数据。在数据集
下面{"地址":{"建设":" 1007"," coord":[ - 73.856077,40.848447],&# 34; street":" Morris Park Ave"," zipcode":" 10462"},"自治市":"布朗克斯","美食":"面包店","成绩":[{" date":{" $ date& #34;:1393804800000},"年级":" A","得分":2},{"约会":{&# 34; $ date":1378857600000},"年级":" A","得分":6},{"日期" :{" $ date":1358985600000},"年级":" A","得分":10},{" date":{" $ date":1322006400000}," grade":" A","得分":9},{ " date":{" $ date":1299715200000}," grade":" B","得分": 14}],"名称":" Morris Park Bake Shop"," restaurant_id":" 30075445"} {"地址":{"建筑":" 469"," coord":[ - 73.961704,40.662942]," street& #34;:" Flatbush" Avenue"," zipcode":" 11225"},"自治市":"布鲁克林","美食" :"汉堡包","成绩":[{"日期":{" $ date":1419897600000},"成绩&# 34;:" A","得分":8},{"约会":{" $ date":1404172800000},&# 34;等级":" B","得分":23},{"约会":{" $ date":1367280000000 },"成绩":" A","得分":12},{"约会":{" $ date&# 34;:1336435200000},"等级":" A","得分":12}],"名称":" Wendy""," restaurant_id":" 30112340"} {"地址":{"建筑":" 351"," coord":[ - 73.98513559999999,40.7676919]," street& #34;:" West 57 Street"," zipcode":" 10019"},"自治市":"曼哈顿&#34 ;,"美食":"爱尔兰","成绩":[{" date":{" $ date" :1409961600000},"等级":" A","得分":2},{"约会":{" $约会":1374451200000},"等级":" A","得分":11},{"约会":{& #34; $ date":1343692800000},"评分":" A","得分":12},{"日期&#34 ;:{" $ date":1325116800000},"年级":" A","得分":12}],&#34 ;姓名":" Dj Reynolds酒吧和餐厅"," restaurant_id":" 30191841"}
当我尝试导入MongoDB时,它会出错 2016-07-10T10:28:10.377-0400失败:错误处理文档#2:无效字符' A'在对象键之后:值对
我们无法更改/删除数据中的双引号,因为它必须按原样存储。
非常感谢任何帮助。
由于
答案 0 :(得分:1)
您的目标是在插入之前确保JSON数据首先有效(您使用的是MongoDB命令行btw吗? 确保在插入之前转义JSON数据。
"street": "Flatbush" Avenue"
应该成为
"street": "Flatbush\" Avenue"
希望有所帮助。