2
返回關於Mongo和LiveCode的更多問題,這次是針對MergJSON特有的問題。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