Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Getting info from a .json (converted to lua) file?
Started by d.mach Apr 14 2019 10:50 AM

- - - - -
1 reply to this topic

Best Answer d.mach , 14 April 2019 - 10:59 AM

Got it:

because the properties part is inside extra brackets it only can get accessed by using this:

waypoints1.objects[y].properties[1].value

 

This is working.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 821 posts
  • Corona SDK

I wonder how to get the data from this .json file (only a part is seen here)

{
         "draworder":"topdown",
         "id":4,
         "name":"Waypoints",
         "objects":[
                {
                 "ellipse":true,
                 "height":8,
                 "id":3,
                 "name":"4",
                 "properties":[
                        {
                         "name":"id",
                         "type":"string",
                         "value":"4"
                        }],
                 "rotation":0,
                 "type":"Waypoint",
                 "visible":true,
                 "width":8,
                 "x":176,
                 "y":238
                },
...

I am using this .json file with converttolua crating a lua file out of it. Then I access the data, like for example:

waypoints1.objects[y].name

this prints "4" like expected.

 

BUT I have trouble to get the data from the properties part because using this:

waypoints1.objects[y].properties.value

is printing an error!

 

How can I access the inside of properties correctly?

 



[TOPIC: post.html]
#2

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 821 posts
  • Corona SDK

  Best Answer

Got it:

because the properties part is inside extra brackets it only can get accessed by using this:

waypoints1.objects[y].properties[1].value

 

This is working.




[topic_controls]
[/topic_controls]