configFile and json issues [WORKAROUND]

I’ve emailed the crap out of Graham, so ive decided to post it here and see what i get, since hes helped me alot already.

Anyway ive been working with configFile and i keep getting errors, i even reverted to the tutorial and that didt help, by slightly modifying the sample of the tutorial to include the JSON file below i can replicate the error.

using lime 3.4

This is the terminal output for the error, and where it traces back to:

lime-utils.lua:1327 attempt to concatenate local \_string   
lime-property.lua:84 --this is where the actual error is generated, when it hits and list or array  
  

Tutorial in question:
http://www.justaddli.me/tutorial.php?t=0&id=14

Json file from tutorial:
[javascript]
{
“type”:“racingCar”,
“waypoints”:[“waypoint1”, “waypoint2”, “waypoint3”],
“colour”:[255, 0, 0],
“otherDetails”:{ “cost”:200, “name”:“Awesome Car” }
}
[/javascript] [import]uid: 63700 topic_id: 14049 reply_id: 314049[/import]

It should be noted that i thought i fixed it when i did this
for example:

“otherDetails”:[javascript]"[/javascript]{ “cost”:200, “name”:“Awesome Car” }[javascript]"[/javascript]

But that made the entire object a string [import]uid: 63700 topic_id: 14049 reply_id: 51749[/import]

Still No dice, does anyone have a Similiar problem, I may just be an idiot, but I really cant get it working.

Also im trying to figure out how i would use Limes Json reader to just load my own file given a path, and return a table of all the properties.

Any ideas? [import]uid: 63700 topic_id: 14049 reply_id: 54717[/import]

Here is the working solution i have

[lua] local jsonFile = function( filename, base )
– set default base dir if none specified
if not base then
base = system.ResourceDirectory;
end

– create a file path for corona i/o
local path = system.pathForFile( filename, base )
– will hold contents of file
local contents

– io.open opens a file at path. returns nil if no file found
local file = io.open( path, “r” )
if file then
– read all contents of file into a string
contents = file:read( “*a” )
io.close( file ) – close the file after using it
end
return contents
end

–variables
local rMapProp = {}
local mapProperties = wMap:getProperties()
local gamePropertiesPath = wMap.properties[“Config”]:getValue()
local obj = json.decode(jsonFile(gamePropertiesPath))

for k, v in pairs(obj) do
print("2: " … k … ", " … type(v))
end[/lua]

“Config” is the property name, in the Map Properties of Tiled, that contains map001.json in this case, this should be quite scalable, i hope this helps someone else [import]uid: 63700 topic_id: 14049 reply_id: 54725[/import]

To read in a Json file yourself you could use one of the Utils functions like so:

[code]

local data = lime.utils.readInTable( “file.json”, System.ResourceDirectory )

[/code] [import]uid: 5833 topic_id: 14049 reply_id: 55782[/import]