[PLUGIN] Load JSON

0 favourites
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • Hi,

    this plugin can load and parse a JSON-file. It can be used for translation of words or phrases - written in an external json-file. The "funny characters" in the demo-JSON-file are unicode characters.

    Because it loads a custom json-file this plugin doesn't work in preview mode.

    ____________________________

    Update v 1.<font color="red">2</font>

    Bugfix - getting entries of keys

    Demo+Plugin+JSON-file v 1.2. (capx for C2 r85)

    (second test with fewer keys)

    ____________________________

    Update v 1.1

    Demo+Plugin+JSON-file v 1.1. (capx for C2 r85)

    Two more expressions:

    1) getRootKeysSize --> return number

    Returns an integer how many keys exists in the JSON-file.

    2) getKeySize(stringKey) --> return number

    Returns an integer how many entries exist at the key- stringKey.

    How to use --> screenshots in my post below

    ____________________________

    Demo+Plugin+Example (v 1.0)

    Property:

    The name of the json-file. [optional path if the file is not located next to the exported index.html]

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/properties.png" border="0">

    Condition:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/conditions.png" border="0">

    Action:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/actions.png" border="0">

    Expressions:

    getData(keyWordAsText,positionAsNumber) --> returns Text

    eg json-data is: "dog": ["Dog", "Cane"]

    getData("dog",0) --> returns "Dog"

    getData("dog",1) --> returns "Cane"

    readLoadingReturn --> returns Text

    show the status of loading: word is found, not found, success, error,..

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/expressions.png" border="0">

    How to use the plugin - overview:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/overView.png" border="0">

    All suggestions are welcome and have fun,

    Joe7

  • I had made a similar plugin named Hash table before.

    However, your plugin seems more directly.

  • rexrainbow: I know your plugin since it was available <img src="smileys/smiley1.gif" border="0" align="middle" />. I have also used JSON-loading with c2 before - but with pure (external) Javascript(-hashtables). Yesterday I've read about a language discussion and so I've decided to make a Plugin for "a simple loading" a "simple JSON-Langugage-file".

  • This is really good!

    Can your plugin handle nested values/multi-dimensional arrays?

  • No.. it's only for simple json. Do we really need support for nested json-structures? I ask because I suppose that the users that use json for complicated savings or readings use php or pure javascript because of the flexibility and time to parse. If I would try to extend this plugin I think it would slow down the reading-time for simple files too. I have an idea how to implement nested things as a plugin but I'm still not sure if anyone will use it or needs it.. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I would welcome it, though the better option would be something native (hint Ashley).

    If I were to make such a plugin, I'd implement it like a jQuery selector (to get around the expression limitations), such as getStringVal("object.value.array[key].anothervalue") and complementary operations, such as getNumberVal and getBoolVal

  • Fimbul Great. Better idea than mine. <img src="smileys/smiley2.gif" border="0" align="middle" />

    I thought at key1.key2.key3 but jquery syntax is much better. I'll try it but in the next days I've no time.. so if it's really important feel free to fork or change the plugin by yourself. I'look at it asap..

  • Great plugin! Keep up the good work!

    Is there a way to count the number of words in the JSON file? I'd like to run a foreach loop that changes, depending on the contents of the JSON file. Also, can I put Construct 2 variables in the JSON URL (ex. to send parameters to a PHP file in order to create the correct JSON file?

    Thanks in advance. I really appreciate it. This is just what I've been looking for! :)

  • No, counting isn't possible this time. Update is on the way. <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tnewhook

    Now with version 1.1 counting is possible. <img src="smileys/smiley2.gif" border="0" align="middle" />

    Two more expressions:

    Get the number of keys:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/expressionRootKeysSize.png" border="0" />

    Get the numbers of entries of a given key:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/expressionKeysSize.png" border="0" />

    short overview:

    <img src="http://dl.dropbox.com/u/31151399/Construct2/Plugins/joe7_loadJson_demo/images/overView1.1.png" border="0" />

  • Super ! ! !

    Thank you very much :))

  • wow! that was fast! Thanks much. One other question... I created a loop that shows all the elements in a particular word. However, if I change the number of words, then I can't see all the elements in a particular word. If I run my demo with your 4-word JSON file, all is well, but if I delete "flower" and "coffee", I can only see "dog" and "cane" from the DOG word, and "cat" and "cato" from the CAT word. All of the other options (perro, hund, chien) show up as "not found".

  • tnewhook: It was a plugin-bug. Thanks for reporting it. Should be fixed in v 1.2 <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Joe7: It works...thanks a ton :)

  • Joe7 - Thanks for all the work you've done. I tried to modify the JS files myself, to try to customize them to what I need, but it's way beyond my current level. Is it possible to dynamically set the JSON file on page load, before calling the "JSON load" function?

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