Firebase“;无效数据,无法';t解析JSON对象……”;
我正在尝试使用解析云代码和Firebase的RESTAPI从Parse向Firebase发出POST请求Firebase“;无效数据,无法';t解析JSON对象……”;,json,parse-platform,firebase,Json,Parse Platform,Firebase,我正在尝试使用解析云代码和Firebase的RESTAPI从Parse向Firebase发出POST请求 Parse.Cloud.define("createChatRoom", function(request, response) { Parse.Cloud.httpRequest({ url: 'https://myapp.firebaseIO.com/' + '.json', method: 'PUT', body: {"hi": "hello"} })
Parse.Cloud.define("createChatRoom", function(request, response) {
Parse.Cloud.httpRequest({
url: 'https://myapp.firebaseIO.com/' + '.json',
method: 'PUT',
body: {"hi": "hello"}
}).then(function(httpResponse) {
response.success("Successfully posted hello!");
},function(httpResponse) {
response.error("failed to post hello" + httpResponse.text)
})
})
但是,此代码使Firebase响应以下错误:
"Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names."
我尝试了大量的body
组合,包括撇号、整数的变体,以及删除括号
有什么想法吗?回答我的问题:
Firebase的JSON必须用单引号括起来”
:
body:'{“hi”:“hello”}
我认为最好像这样使用body:JSON.stringify({“hi”:“hello”})