【发布时间】:2014-02-24 22:02:09
【问题描述】:
在 LiveCode 中,我有一个连接到本地 MongoDB 的堆栈,该堆栈有一个带有 mouseup 处理程序的按钮和来自 MergJSON 的函数 JSONToArray 和两个字段:“A”接收服务器回答“原样”和字段 B“接收解码后的 JSON。
这是按钮的脚本:
on mouseup
set the hideConsoleWindows to true
put shell("C:\\mongodb\bin\mongo.exe --eval" && quote & \
"printjson(db.test.findOne())" & quote) into pJSON
put pJSON into fld "a"
put JSONToArray(pJSON) into tArray
put tArray["a"] into fld "B"
end mouseup
mouseup后fld“A”的内容为:
MongoDB shell version: 2.2.7
connecting to: test
{ "_id" : ObjectId("52e3f87c8da8b1efb07004c9"), "a" : 1 }
脚本失败并出现以下 LiveCode 错误:
executing at 8:58:32 PM
Type could not decode JSON: invalid token near 'MongoDB'
Object Completo
Line repeat for each line tKey in mergJSONDecode(pJSON,"tArray")
Hint could not decode JSON: invalid token near 'MongoDB'
如果我将脚本更改为:
on mouseup
put shell("C:\\mongodb\bin\mongo.exe --eval" && quote & "printjson(db.test.find())" & quote) into pJSON
put pJSON into fld "A"
end mouseup
字段“A”得到这个:
MongoDB shell version: 2.2.7
connecting to: test
{
_"_mongo" : connection to 127.0.0.1,
_"_db" : test,
_"_collection" : test.test
_"_ns" : "test.test",
_"_query" : {
__
_},
_"_fields" : null,
_"_limit" : 0,
_"_skip" : 0,
_"_batchSize" : 0,
_"_options" : 0,
_"_cursor" : null,
_"_numReturned" : 0,
_"_special" : false,
_"help" : function () {
print("find() modifiers");
...
...
...
}
我正在缩短实际字段“A”的内容,它有很多文字。
你能指导我吗?我做错了什么?为什么我没有得到 JSON。我使用在线服务检查了{ "_id" : ObjectId("52e3f87c8da8b1efb07004c9"), "a" : 1 },发现它不是有效的 JSON。
【问题讨论】: