When to use XML versus JSON in C2?

Get help using Construct 2

Post » Sun Feb 24, 2013 2:29 am

I'm trying to design a dialogue system, and I believe I'd prefer to use JSON over XML. I feel like I need the ability to use nested structures, but from what I understand C2 supports a limited dialect of JSON which can be seen when using the Download action on Arrays and Dictionaries.

It appears I can get nesting in XML, so I will use it as a last resort.
https://www.scirra.com/tutorials/354/xml-parsing

However, if anyone knows how one could load the following JSON dialogue and parse it let me know. I tried loading it into a Dictionary but it never worked for me.

Also, here's a link explaining why JSON is better than XML: http://www.json.org/xml.html

[code]{
    "fallingFromTheMountain001": {
        "normal": {
            "blocks": [
               {
                    "portrait": "Kain",
                    "text": [
                        "I'm fine, thank you..",
                        "You know you really didn't have to do all of this.."
                    ]
               },
               {
                    "portrait": "Tellah",
                    "text": [
                        "Oh no worries at all. A life is a valuable thing.",
                        "I'm just glad these old bones were still up to such a task, haha.",
                        "So tell me, why were you trying to climb that mountain?"
                    ],
                    "options": [
                        {
                            "response": "It's none of your business.",
                            "goto": "fallingFromTheMountain002",
                            "type": "wary"
                        },{
                            "response": "Something terrible happened there..I'm looking for answers.",
                            "goto": "fallingFromTheMountain002",
                            "type": "normal"
                        }
                    ]
               }
            ]
        }
    },
    "fallingFromTheMountain002": {
        "normal": {
            "blocks": [
               {
                    "portrait": "Tellah",
                    "text": [
                        "Oh? Well then take this..."                     
                    ],
                    "itemGet":"OldCaveKey"
               }
            ]
        },
        "wary": {
            "blocks": [
               {
                    "portrait": "Kain",
                    "text": [
                        "I don't know who you are and there are people after me for what I know.",
                        "So I don't trust you yet."
                    ]
               },
               {
                    "portrait": "Tellah",
                    "text": [
                        "Fine by me. Take as much time as you like."
                    ]
               }
            ]
        }
    }
}[/code]
Asmodeus2013-02-24 02:51:28
B
9
S
2
Posts: 25
Reputation: 1,050

Post » Sun Feb 24, 2013 4:34 am

Honestly, JSON uses a lot of {} and [] than <> makes harder to read, i don't believe this page JSON is simple than XML
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Sun Feb 24, 2013 12:28 pm

The XML object isn't supported for CoCoonJS, so if you wanted to store the data locally and support Mobile via CocoonJS, JSON is your friend.
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Thu Feb 28, 2013 5:32 am

For now I've just decided to move on with XML.

If anyone is interested in writing their logic in JSON, you can convert it to XML just by clicking a button: http://www.freeformatter.com/json-to-xml-converter.html

B
9
S
2
Posts: 25
Reputation: 1,050


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests