When to use XML versus JSON in C2?

0 favourites
  • 4 posts
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • 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.

    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: json.org/xml.html

    {
        "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."
                        ]
                    }
                ]
            }
        }
    }
  • Honestly, JSON uses a lot of {} and [] than <> makes harder to read, i don't believe this page JSON is simple than XML

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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: freeformatter.com/json-to-xml-converter.html

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)