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

Post your work in progress addons and get feedback

Post » Thu Jan 21, 2016 9:28 am

@esfand55

This Yann's JSON plugin already could create JSON structure. Or you might try this plugin.
B
108
S
26
G
267
Posts: 4,455
Reputation: 149,745

Post » Fri Jan 22, 2016 10:18 am

@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?
B
108
S
26
G
267
Posts: 4,455
Reputation: 149,745

Post » Thu Mar 24, 2016 5:36 am

is there the function to shuffle json data?

Thank you,
Pooh
B
3
Posts: 1
Reputation: 177

Post » Wed Apr 27, 2016 10:55 am

Great work on the plugin....

Has stability been confirm as yet?
B
17
S
4
Posts: 3
Reputation: 931

Post » Thu Apr 28, 2016 5:11 pm

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
Code: Select all
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
}


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 :)
B
3
Posts: 4
Reputation: 183

Post » Fri Apr 29, 2016 7:45 pm

@mfdeveloper

I'm not using construct that much these days. But if I remember correctly the plugin has something like
Code: Select all
LoadJSON "{""name"": ""test"", ""age"",""xxx""}" at [email protected]'some','kind','of','path'

which would exactly achieve what you described without having some nasty parsing. Something like
Code: Select all
Set Value "{o_o}" at [email protected] 'smilies','0'
should be expected to work

has for sharing things on github, yeah, I should, three years ago I wasn't really using it that much so I didn't have this reflex.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Sun May 08, 2016 11:59 am

Hi. When I try to load json data from AJAX.LastData I get this error:

Javascript error!
invalid character
http://myIP/JSON_plugin.js, line 472 (col 9)

this is the data from AJAX.Last Data:
test({"realms":[{"type":"rp","population":"medium","queue":false,"wintergrasp":{"area":1,"controlling-faction":1,"status":0,"next":1462710723426},"tol-barad":{"area":21,"controlling-faction":0,"status":0,"next":1462709800605},"status":true,"name":"Zirkel des Cenarius","slug":"zirkel-des-cenarius","battlegroup":"Embuscade / Hinterhalt","locale":"de_DE","timezone":"Europe/Paris","connected_realms":["zirkel-des-cenarius","todeswache"]}]});

OR:
{"realms":[{"type":"rp","population":"medium","queue":false,"wintergrasp":{"area":1,"controlling-faction":1,"status":0,"next":1462710723768},"tol-barad":{"area":21,"controlling-faction":0,"status":1,"next":1462710700949},"status":true,"name":"Zirkel des Cenarius","slug":"zirkel-des-cenarius","battlegroup":"Embuscade / Hinterhalt","locale":"de_DE","timezone":"Europe/Paris","connected_realms":["zirkel-des-cenarius","todeswache"]}]}


what invalid character?
even if I remove "({"realms":" at the start and "});" at the end I get an error.
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Mon May 09, 2016 6:04 am

@Bl4ckSh33p

I see no problem here
make sure you load a proper JSON string.
Good test is to copy paste the exact input you try to load in http://jsonlint.com and see if it's a valid string.
for example
Code: Select all
{"realms": []}
is a valid json string, but
Code: Select all
test({"realms": []})
is obviously not.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Tue May 10, 2016 9:02 pm

Hello Yann,

Has there been any new development, or syntax cleanups for this plugin ?

This looks promising

Hugo
B
5
S
1
Posts: 10
Reputation: 419

Post » Mon May 30, 2016 9:29 am

Hi,

Is it possible to delete an element of an array? Currently, what I've tried so far is that I can delete an element of an object, but not array. When I use "delete" action and set the keys into an array, it just emptied the array, making it null. What matter is when I try to get the size (eg: JSON.Size(0, "data"), the null elements are counted as well. Can I delete the element entirely so it wont be counted? Or am I doing it wrong?

Regards,
Alvin
B
33
S
10
G
2
Posts: 46
Reputation: 3,063

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: Lof and 1 guest