How do I use JSON

0 favourites
  • 6 posts
  • Hi all,

    I'd like to use the JSON format as easily as in programming code.

    Is that possible in C2 to use JSON as easily ? without using dictionnaries or arrays ?

    For example, a JSON variable like :

    myVar = {"pseudo" : "Adisma", "level" : 8}

    And use it as :

    myVar.pseudo

    myVar.level

    I didn't find any plugin allowing this..

    Thanks in advance

  • You can use Token At, and then you can do any kind of "Code" you want. Can use .Json, or just make a psudo code.

    Just use an array, Dictionary , or an object with instance variables and save and load as Json. This is the easiest for most people.

    The Token At is the Most like real programming. It is Cryptic, and hard to read, and hard to edit. It take special knowledge to use it, and most people will not understand it at first. It is easy to make typos, and takes special loops to actually read and use. Perfect for programmers!

    So basically If you want it "easy as" Construct 2, then simply use an array or a dictionary, or use instance variables. Then simply save and load as json.

    Or if you want to over complicate things, and make it "easy as in programming" then Token count and Token At is your best solution.

    You can even over complicate things with XML if you want it really easy.

    I am still waiting for someone to do a plugin for this:

    https://goo.gl/vfgFK7

  • Doing something a different way from what you are used to doesn't make it harder..

    Learning new ways to do things are an essential part of programming..

    Instead of calling it "asking for the easy way", some people would call it "asking for the lazy way"..

    (Not that I'm that kind of a person, offcourse)

    I think this plugin might suit you:

    Plugin json

  • Doing something a different way from what you are used to doesn't make it harder.

    Totally agree. Learning the C2 way of doing things just take a little extra effort. In cases like this it will be much faster than using Plugin or having to extensively use Token At and token count to retrieve things.

    You can simply retrieve a value from an array, you do not need to bog down the CPU with Token at, Dictionary or loops. You dont need a plugin that may cause incompatibility problems in the future.

    By simply learning the C2 way of doing things, it is not only easier to debug, it is also much faster then re-inventing the wheel. Not to mention it is safer, and you dont have to bloat your application with a bunch of json files.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Doing something a different way from what you are used to doesn't make it harder..

    Learning new ways to do things are an essential part of programming..

    Instead of calling it "asking for the easy way", some people would call it "asking for the lazy way"..

    (Not that I'm that kind of a person, offcourse)

    I think this plugin might suit you:

    Plugin json

    It should

    I will try it.

    Moreover, I'll try the Hash Table plugin from rex that might help too..

    I'll try both and use the best for my use (e.g. using JSON coming from AJAX request).

    Thanks all of you..

  • Glad I could help..

    I should warn you, though, that using those plugins might really diminish the amount of help you are able to get on the forums..

    People who don't have them installed can't open your project and will have no clue as to how to work eith them anyway..

    Good luck on your project!

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