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

Post your work in progress addons and get feedback

Post » Sun Mar 23, 2014 11:02 pm

Awesome!

Any eta on some stable release? I mean, I would love to use in my current project (could make my life sooo easy) but on the other hand I don't want to find out one day that everything stopped working cause you change/remove something :D

Great work!
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Sun Mar 23, 2014 11:06 pm

@shinkan
Well, for now I didn't have any complain (not sure anyone really tested it).
But I'd say, a safe one or two weeks would be a fair minimum
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Mon Mar 24, 2014 12:25 am

well i for one am currently looking into it and try to wrap my head around the plugin, but its looking good, the json file example is a good one to see how to iterate thru everything..

questions that come to mind is,

what will be the best way to import certain data, (maybe rex csv to ... ) or straight from a json editor
exporting and saving the json string / edit : ok thats covered ... ToJson

yes, it takes some time to really give good feedback or find problems, only way to know will be trying things out i guess, or wait
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Mon Mar 24, 2014 12:39 am

a use case i want to test, is having a list of objects, and then an array that links to an id of one of the objects to get that info

i wonder if looping thru objects instead of properties would be a usefull

if you have weapon(s) object, do you create a new object for each weapon or create new weapons thru properties ( thinking ;) )
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Mon Mar 24, 2014 1:30 am

Yeah should have gone calling it something like keypair.
Image ImageImage
B
169
S
50
G
174
Posts: 8,331
Reputation: 110,806

Post » Mon Mar 24, 2014 3:05 am

not sure how i can add new entry's in a array object, from the inspection capx example, i guess the root object is an array, these contain 5 objects, and these objects has all the data and furter nested arrays


found this nice online editor

http://www.jsoneditoronline.org/
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Mon Mar 24, 2014 9:16 am

@vtrix
I'm at work now, but know that the root object can be whatever you want it to be: an object (a.k.a. dictionary), an array, a boolean, a number, a string or null.
By default, root is undefined (or should be, I don't remember what I do :D)
The brackets [] you see in the event sheet are just because I don't have a lot of options as far as formating the look of action/condition/expression. Those brackets should contain the path to a value. Nothing to do with type.

In the example with the Wizard class,
- root[] is the base (which in this case is an object)
- root["Wizard"] is the value at the "wizard" key in the root object, and it is also an object
- root["Wizard","hp"] is the value at the "hp" key contains in the object at the "Wizard" key of the root object.
and so on and so forth.

I'll keep calling this type "object", because that's what it is called in the official JSON documentation and in javascript, but do think of it as a dictionary (key value pair)

As far as confusion with objects in construct...
Well in construct you don't really have objects per se.
You have plugins, object-types (created from plugins) and instances (created from object-types).
You don't really have "objects" (well, the term is usually mis-used interchangeably as a shorthand for object-types or instances... talking about confusion :D).
And in any case, object-types or instances have nothing to do with a JSON object.

I repeat again, an object in JSON is the same as a dictionary in construct2 (and in python it's also called a dictionary)
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Mon Mar 24, 2014 12:35 pm

yes, i agree the object term is just whats used in json and should stay like this, im just going thru the plugin and actually the json structure and making sense of it, here are some reference i found usefull,

http://www.w3resource.com/JSON/structures.php
http://json.org/
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Mon Mar 24, 2014 1:01 pm

@Yann
Been playing with with this last night, and all morning and looks great so far.
[ ] brackets are a little misleading maybe instead use curly brackets { } like in "typical" json, and keep [ ] brackets for arrays to avoid confusion.

set 2 at current{"dex"}

think it looks a bit better then:

set 2 at current["dex"]

or maybe even none of them, just:

set 2 at current "dex"

just a thought :)
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Mon Mar 24, 2014 2:27 pm

Found one issue, nothing fancy but still.

Like on attached image.
if your cursor is currently on "Value" and you press TAB couple of time it goes from "Value" to "Reference point" and then to "Add parameter".
TAB'ing ignores added parameters, but Shift+TAB works fine - moves backwards from "Add parameter" through "Key 1", "Key 0".... to Value"


Edit: Sorry for that huge image, it looks smaller while saving it ;)
You do not have the required permissions to view the files attached to this post.
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests