【发布时间】:2014-03-19 14:25:46
【问题描述】:
返回更多关于 Mongo 和 LiveCode 的问题,这次是针对 MergJSON 的问题。
情况是这样的: 在previous posts 我问了一些关于如何连接并从查询中获取结果的问题,这些问题在哪里得到了回答。
现在,我在 LiveCode 字段中从 Mongo 返回了文档(用于验证目的)。
这是返回的文件:
{ "_id" : "001003", "nombre" : "Pedro" }
{ "_id" : "001004", "nombre" : "Alejandro" }
{ "_id" : "001005", "nombre" : "Mario" }
{ "_id" : "001001", "nombre" : "Javier" }
{ "_id" : "001002", "nombre" : "Andrecillo" }
我现在想要的,但无法工作的是,我的堆栈有一个按钮脚本我有一个 mouseup 处理程序:
on mouseUp
local dbText, dbResultado
set the hideConsoleWindows to true
put "var c=db.nueva.find();" into dbText
put " while(c.hasNext())" after dbText
put " printjson(c.next())" after dbText
put shell("C:\mongodb\bin\mongo.exe --eval" && quote & dbText & quote) into dbResultado
put line 3 to -1 of dbResultado into pJSON
put pJSON into field "A" -- just to see what Mongo is returning after eliminating line 1 and 2 of dbResultado
put JSONToArray(pJSON) into tArray
put tArray["nombre"] into fld "B"
end mouseUp
在这个处理程序之后是解码和编码函数。
运行此脚本时出现错误:
executing at 10:15:18 AM
Type could not decode JSON: end of file expected near '{'
Object Mejoraddo
Line repeat for each line tKey in mergJSONDecode(pJSON,"tArray")
Hint could not decode JSON: end of file expected near '{'
在这行函数JSONToArray pJSON中:
repeat for each line tKey in mergJSONDecode(pJSON,"tArray")
我几乎可以肯定我错过了一个简单的步骤或监督一些明显的事情。请,如果您需要一些澄清,我会尝试更好地解释这一点,提前致谢,
Javier
【问题讨论】: