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

Post your work in progress addons and get feedback

Post » Fri Mar 21, 2014 12:21 am

Hi there,

New version 1.2

Now all the code and documentation is hosted on github

Download links are right here:

ChangeLog
v1.2 - 2016-06-05
    - New Shared Reference system
    - Push and Pop Path Node into CurrentPath
    - Fix: Delete on array was setting the item to undefined without removing
    it, so Length and Size wasn't displaying the proper value
    - Fix: Delete and Clear in general (I was doing something stoopid)
v1.1 - 2014-04-17
    - implement save/load/debugger
    - ToJson deprecated and replaced by AsJson for overall coherence
    - change the brackets syntax for a less confusing one (I hope)
    Code: Select all
    before: root["Wizard","stats","hp"]
    after:  [email protected]"Wizard","stats","hp"
    - change Length for Size and handle object/array return -1 for anything else
    - isEmpty condition and Clear action for array and object
    - add a CurrentValue property
    - in foreach loop reset the current path to the path given at the begining on each iteration, this way we can mess with this current path to our heart content within the loop
    - more reliable logData
Last edited by Yann on Sun Jun 05, 2016 12:04 am, edited 12 times in total.
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Post » Fri Mar 21, 2014 1:54 am

really useful! thank you, @Yann
ImageImage
B
83
S
27
G
8
Posts: 191
Reputation: 11,095

Post » Fri Mar 21, 2014 2:12 am

Yup, another plug that should be "officially" supported.
The data types are kinda weird, like learning lucids "S".

Edit:
Need a good editor now.
Image ImageImage
B
172
S
50
G
182
Posts: 8,439
Reputation: 115,097

Post » Fri Mar 21, 2014 7:01 am

Nice!

It might be better to have array operation like push, pop ...
B
110
S
28
G
280
Posts: 4,487
Reputation: 156,566

Post » Fri Mar 21, 2014 8:32 am

@newt
care to explain what you mean by "the data types are kinda weird?"
it's a direct translation of JSON's 6 basic datatypes (object, array, number, string, boolean, null)
In the set Value action I bundle number and string together because they are the only two basic datatype you can manipulate on C2.

@rexrainbow
Yes, but if I start implementing array functions it might make the plugin a bit too cluttered. I prefer to start with something a bit bare and see if people manage to use it well. (and if I have to make design changes it's easier ;) )

Also I might have to implement n00b securities like try catching attempts to access invalid path, so the exported application wouldn't crash.
Something like
Code: Select all
try {
   // access some part of object that might fail with "undefined doesn't have a property called ***"
} catch (e) {
     if (cr.in_preview()) { // don't remember the exact function
          throw e;
     }
}
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Post » Fri Mar 21, 2014 3:24 pm

Its just that the term object is a little ambiguous, and could lead to some confusion over actual layout objects.
Image ImageImage
B
172
S
50
G
182
Posts: 8,439
Reputation: 115,097

Post » Fri Mar 21, 2014 7:32 pm

@newt
yeah, I indeed thought about that and I think that renaming "object" to something else would generate even more confusion. I could name it "dictionary" but it would lead to confusion with the dictionary plugin. And in the end, it's an JSON object so meh. The confusion, if it happens, shouldn't last too long in the mind of someone using JSON.
Thanks for the clarification.
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Post » Sat Mar 22, 2014 3:40 pm

@Yann , this is amazing work, will probably become my favorite plugin, so thank you, i was currently working alot with arrays, and was searching for a good system to have arrays in arrays recursively, for anything that needs a directory like structure, but a json structure is a complete solution, and is way better. (i still need to test it but it looks great)

now if we only could use the dot notation for the created objects, something like get JSON.classes.thief.hp, + i also read recently that object variables can now be accessed by plugins, by AddObjectInstanceVarParam, im not 100% but maybe there's some possibilities in exchanging data from json to object variables

anyway will test this in coming week..
ImageImage
B
71
S
22
G
7
Posts: 827
Reputation: 10,177

Post » Sat Mar 22, 2014 5:46 pm

@Yann
Wow, very nice. I'm hesitant to use it with my current game, but I surely could use it.
B
11
S
1
G
1
Posts: 81
Reputation: 892

Post » Sat Mar 22, 2014 6:59 pm

@Smolli
I probably won't drop support for this plugin anytime soon. But you should at least wait for people to test proof it a bit.
As I wrote, I'm still not 100% sure about the clarity of the design. (Mostly if using the function parameters UI is a good idea or not). And I'd like the freedom to add/remove action/condition/expressions as I see fit.
When this plugin will be referenced in the completed plugins forum, I'll insure backward compatibility (marking the thing I will want to change as deprecated) but for now, nope!

@vtrix
Thanks
Well, indirectly I could somehow implement some kind of dot notation using string, but it would require string parsing which would be slower. And it would looks like classes.Value(0,"Wizard.stats.hp") instead of classes.Value(0,"Wizard","stats","hp")
So...
Dot notation would require a very big change in how C2 editor works. Because it would have to allow uncheckable things.
classes.Wizard.stats.hp in C2 means, for now, that your object has a behavior named Wizard which has a stats property and.... Well C2 just really can't for now.
Also I don't think that The new AddObjectInstanceVarParam would be of any use for the JSON plugin since it's closer to the Array or Dictionary plugin. They are just data manipulation plugins, they shouldn't directly manipulate other objects.
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Next

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests