[plugin] JSON (import/export/generate/edit/inspect/...)

0 favourites
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • CrazyVulcan

    As big as your browser/device can handle (:

  • This plugin was exactly what I needed. Great job. Thank you!

  • Try Construct 3

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

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

    I updated to Construct2 212.2 and have now troubles using the pluging. Am I'm the only one?

    Error:

    [quote:av3bthxg]Unable to load behavior in "C:\Program Files\Construct2\exporters\html5\behavior\json-v1.1\": Javascript exception in file "edittime.js" line 65: RefernceError: AddVariadicParams is not defined

    Code line:

    AddVariadicParams("Key{n},"Key or index to get the value. If no key is

    Stack trace:

    ReferenceError: AddVariadicParams is not defined

    at keyPath(edittime.js:65:5)

    at edittime.js:76:1

    This behavior will not be available in the editor

  • Hmmm...

    edwardr

    Are you sure you didn't do more than just updating?

    'cause, I already see something wrong here:

    C:\Program Files\Construct2\exporters\html5[b]behavior\json-v1.1

    the .js and .ico files of the plugin are supposed to go in

    C:\Program Files\Construct2\exporters\html5[b]plugins\json\</p>

  • I tried it in plugins, but it doesn't appeared. Then I put in behavior, there comes the error.

    But anyway I got some additional other errors, so I deinstalled Construct and installed it again. Now everything is fine, it seems something went wrong during the last Installation.

    sorry for the worries I caused.

  • It's me again <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I just need a small re-thinking or tips to reduce some programing. It's working but it's really "dirty" and I'm not so happy about it and maybe it will get complicated if I make some changes in the future

    Situation:

    I have several databases, which stands for each research category and in each database there are several upgrades with their specific requirements. So if you click an Overview-Icon the specific database will be loaded, the actual upgrade level will be shown and you can research the next level.

    Database - Weapon
    new Object at root@
    Set Current Path to rootjfz@1
    Set "1st Upgrade" at current@"Text"
    Set 100 at current@"Time"
    Set 400 at current@"Price"
    Set "Image1" at current@"Image"
    
    Set Current Path to rootjfz@2
    Set "2st Upgrade" at current@"Text"
    Set 120 at current@"Time"
    Set 420 at current@"Price"
    Set "Image2" at current@"Image"[/[/code:2353rp54]
    
    [b]This works, BUT... [/b]
    for each category I have to copy the programming but with other database-name and then I also have so many json files. 
    a simple version: [url=http://1drv.ms/1O7unzm]http://1drv.ms/1O7unzm[/url]
    [b]
    Is there a possibility to reduce it in one database? [/b]
    When I click an image, I pass with function() the parameters, so I need just one programming and one database. I need something like an over-root? (The root name should be a number, so I just can add or substract by 1 and jump so through the level)
    
    e.g. 
    Weapon_Json.value(0,1,"Description")  -> All_Json.Value("Weapon",1,"Description")
    (in Detail: 
    All_Json.Value(Function.Param(0),Variable1,"Description")     function.param(0) stands for the Paramater which is passed trough and variable1 the current level (e.g.))
  • ok, I'm coming closer. I found a mistake and corrected it. Now it makes a loop and search the specific datas, but it loops endless... ???

    I updated the sample: http://1drv.ms/1O7unzm

  • Yann How can I add values to the array? There is an action to add an empty array, but now way to add/remove values to it.

    Edit: OK, found it out, you can set new values by specifying the array index as the second parameter in SetValue function. Push/Pop would be very helpful, though.

  • Yann , You can't seem to create a loop inside another loop. How can I do this?

    edit: nevermind, I managed to do it with a call to a function.. This now allows me to loop through any nested objects however many levels deep.

  • Hi there,

    I would like to create a json structure like this:

    {

    "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter","lastName":"Jones"} ]

    }

    There is an array of employees. I'm stuck creating this array.

    Any help will be appreciated.

    Thanks

  • esfand55

    This Yann's JSON plugin already could create JSON structure. Or you might try this plugin.

  • Yann

    I try to go through a dictionary which has a lot of keys, for example 10,000 keys. It will hold the engine if using for each condition.

    My solution is transfer keys into an array then go through this array in ticks ( for example, repeat 1000 keys in a tick ).

    I found that Object.keys() method could get keys list back. Could you add this feature into JSON plugin? Maybe an action to assign a key path of the object, and another JSON object for output.

    Or is there any better solution?

  • is there the function to shuffle json data?

    Thank you,

    Pooh

  • Great work on the plugin....

    Has stability been confirm as yet?

  • Hello @Yann !!

    Your plugin is great and works like a charm for me! I'm using to configure and store a inventory mechanic rules!!

    However, I found a limitation: "The Set Value action not allow pass a JSON, only string or number". So, I implemented this change:

    from line 216

    if(/^\{*.*\}$/.test(value)){
       /** Parse JSON string here. This method needs a well formated json, like this:
       * {"name": "test", "age","xxx"}
       * So, you need pass a double quoted attributes and values. Otherwise, you will catch a
       */ parse exception on browser console log.
       value = JSON.parse(value);
    }
                          
    /** Additionally, add more elements instead override all values of the path, 
    * if the type of the last path is a array.
    */ 
    if(type(obj[path_[i]]) === "array"){ 
       obj[path_[i]].push(value);
    }else{
       obj[path_[i]] = value; // silently create a new property if doesn't exist yet
    }
    [/code:3c9sxq1s]
    
    How can I share this code snippet with you? Do you store the code of this plugin in some remote repository? (github, gitlab...) ? If yes, share with us to contribute with you
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)