gpt4 book ai didi

arrays - Node : How to store JSON Array in google datastore

转载 作者:太空宇宙 更新时间:2023-11-04 02:17:46 25 4
gpt4 key购买 nike

我尝试使用nodeJS在Google数据存储中存储以下对象,但它返回400“错误请求”错误

{
"_id":{
"$oid":"567e9e80067de880273095e0"
},
"name":"Windows 10",
"desc":"This is a Test",
"isSelfPaced":true,
"credit":[
{
"_id":"56640d4926b67c201b861cde",
"username":"Akash",
"displayName":"Gupta",
"email":"yesitsakash@gmail.com",
"role":"Author"
}
],

"video":{
"type":0,
"videoKey":"KHATEmotionalFulls_lowb84c0084-836c-008c-a850-328687e23d02.mp4",

},

"structure":4,
"category":"test2",
"subCategory":"dfdfdf",
"content":[
{
"id":"a053915c-8d10-4aa8-b464-c8a99154c3af",
"name":"Module 1",
"type":1,
"topics":[
"test1",
"test2"
],
"children":[
{
"id":"46f18a1a-6653-41cb-be5c-002200170bb9",
"name":"Unit 1",
"type":2,
"subtype":"1",
"video":{
"type":0,
"videoKey":"VID-20150920-WA0017ee56049d-2b08-aeb5-9b9c-b5188b1f7324.mp4",

},
"note":"<ul><li><b>This is a test<\/b><\/li><\/ul>",
"isSelfPaced":true
},
{
"id":"da4f53a3-7ea2-4fa8-9d48-4d7199a3450c",
"name":"quiz 1",
"type":2,
"subtype":3,
"questions":[
{
"question":"New Question",
"options":[
{
"text":"option 1",
"correct":true
}
]
}
],
"isSelfPaced":true
}
],
"time":3,
"isSelfPaced":true,
"desc":"This is a test"
}
],
"createdBy":{
"displayName":"Gupta",
"id":"56640d4926b67c201b861cde"
},
"createdAt":{
"$date":"2016-01-10T17:51:15.635Z"
},
"startDate":"1970-01-01T00:00:00.000Z",
"endDate":"1970-01-01T00:00:00.000Z",
"isPublish":true
};
datastore.insert('test2','test2',data,function(err,key){
if(err){
res.status(500).end();
}
else{
res.send(key);
}
});
});

NodeJS 代码:

var keyObject = dataset.key({
namespace: namespace,
path: [collectionName,utility.getGUID()]
});
dataset.save({key:keyObject,data:data,method:'insert'},function(err) {
if(err){
callback(err,null);
}
else{
callback(null,keyObject.path[1]);
}

});

更简单的场景正在运行,但如何使用nodejs将json数组存储在谷歌数据存储中

最佳答案

问题是 JSON 负载格式错误。

关于arrays - Node : How to store JSON Array in google datastore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34919247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com