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
Http放入JSON存储_Json_Http_Couchdb_Put_Livecode - Fatal编程技术网

Http放入JSON存储

Http放入JSON存储,json,http,couchdb,put,livecode,Json,Http,Couchdb,Put,Livecode,以下JavaScript代码片段的LiveCode等价物是什么 var req = new XMLHttpRequest(); req.open("PUT", theURLoftheNoSQLstore, false); req.setRequestHeader('Content-Type', mimeType); req.send(theJSONobjString); 这些参数已定义为

以下JavaScript代码片段的LiveCode等价物是什么

            var req = new XMLHttpRequest();
            req.open("PUT", theURLoftheNoSQLstore, false);  
            req.setRequestHeader('Content-Type', mimeType);
            req.send(theJSONobjString); 
这些参数已定义为

            theJSONobj   = {};
            theJSONobj["aKey"] = "aValue";
            theJSONobj["anotherKey"] = 123;
            theJSONobj["note"] = "some note about the issue";
            theJSONobjString = JSON.stringify(theJSONobj);
            theURLoftheNoSQLstore ="http://localhost:5984/thedb/thekey"

            mimeType="application/json";
注意

已添加设置mimeType以确保完整性。但是,对于发布到JSON存储区,这是不必要的,因为这是本例中的默认设置(couchDB)

参考资料



与JavaScript相当的Live Code应该是:

set the httpHeaders to "Content-Type: application/json"
put "[" into myJson
// add one record
put "{'key1':'data1','key2':'data2'}" after myJson
// don't forget commas between multiple records
put "]" after myJson
// next line may not work with more complex data
replace "'" with quote in myJson
// server must be able to process PUT
put myJson into URL "http://localhost:5984/thedb/thekey"
put the result into rslt
if rslt is not empty then
  beep
  answer error rslt
end if

在发送JSON对象而不是JSON数组的情况下,couchdb可以很好地工作。所以只有{“key1”:“data1”,“key2”:“data2”}而不是[{“key1”:“data1”,“key2”:“data2”}]我不认为汉内斯在任何地方提到过移动设备,或者我忽略了它?不,你没有,这只是一个注释,以防万一我已经在Ubuntu12.04(LTS)上用LiveCode 6.0测试过它。在使用的数据库上。。。