1

I have the simplest of scripts in LiveCode attempting to parse a small chunk of JSON using the MergJSON library.

This is doubtless something stupid I'm doing as it's been a long day, but I just can't get the JSON parsed into a LiveCode array:

LC Script in a button called 'Connect'

function JSONToArray pJSON
   local tArray,tKeys
   repeat for each line tKey in mergJSONDecode(pJSON,"tArray")
   put JSONToArray(tArray[tKey]) into tArray[tKey]
   end repeat
   return tArray
end JSONToArray

on mouseUp
   put field "MyJSON" into pJSON
   answer JSONToArray()
end mouseUp

My JSON

{
"firstname":"Mary",
"lastname":"Smith",
}

The Error:

Button "Connect": execution error at line n/a (External handler: exception) near "could not decode JSON: unexpected token near end of file"

Suggestions would be most welcome....

Thanks,

Steve

4

2 回答 2

0
{
"firstname":"Mary",
"lastname":"Smith",   <---dangling comma
}
于 2013-05-14T14:35:45.350 回答
0

Mark B might have it but the other thing could be that you're not passing the parameter to JSONToArray...

put JSONToArray(pJSON) into tArray
put tArray["firstname"]
于 2013-05-15T05:43:34.867 回答