Re: [json-schema] json schema and JSONARY questions

191 views
Skip to first unread message

Francis Galiegue

unread,
Mar 20, 2013, 6:47:18 AM3/20/13
to json-...@googlegroups.com
Hello,

On Wed, Mar 20, 2013 at 11:34 AM, <ognian.t...@ogi-it.com> wrote:
[...]
> 1. The order of appearance of the JSON attributes is not defined. Is there a
> way via json-schema to enter such an order or do I have to add such an
> attribute to json schema (Maybe an attribute like visualApperance which can
> contain custom attributes or so??).

JSON, aka RFC 4627, does not define any order, so JSON Schema cannot
guarantee any order. If there is such an order, it will be
implementation-dependent in any case.

(JSON does not even define parsing behaviour in case of duplicate keys!)

--
Francis Galiegue, fgal...@gmail.com
JSON Schema in Java: http://json-schema-validator.herokuapp.com

Geraint

unread,
Mar 20, 2013, 7:36:08 AM3/20/13
to json-...@googlegroups.com
Developer of Jsonary here:

1) There is no keyword in JSON Schema that specifies display order, and it is highly unlikely that there ever will be - it is a visual concern, which is outside the scope for JSON Schema.

However, I have indeed considered including support for such ui-based properties in Jsonary, as I feel it would be useful when using the default renderers.  I was considering "displayOrder", which would work a bit like "z-order" in CSS.  If you want this feature, I could put it into Jsonary fairly soon, as it's quite simple.

2) I see you have commented on the Jsonary GitHub issue for this.  I'll continue that discussion there. :)

3) The "visual readOnly" attribute is exactly what section 4.4 of the hyper-schema spec defines - it has no effect on validation (the property must still be present if it's listed in "required") but the property should be unchanged when submitting data back to the server.  There is a GitHub issue about support for this keyword in Jsonary - I also really want this feature, but I haven't got around to it partly because I spent the last month moving house.

I hope that helps...

On Wednesday, March 20, 2013 10:34:00 AM UTC, Ognian wrote:
Hello,
Since I feel new to json-schema and js I would like to get some feedback if I am on the right road.
Let me explain what I'm doing:
I'm using json-schema to validate json data entered by an user on both, the client side (browser) and on the server side (node.js) where I put the data into mongodb.
Using the same validator (kriszyp/json-schema) on both sides assures (at least I hope so) that all errors are properly signaled to the user in the browser before it comes to the server...
I was searching for a js lib taking the GUI Part of rendering the JSON structure and found a lot of such solutions based on json schema, but only the following seemed suitable for my needs:
I tried alpaca.js, but found that it has to much overhead in doeing things.., but the main problem was that it had an "own" validator, so I would end with 2 different validators on client and server which is really bad.
I took a look at garycourt/JSVForms which is a very good starting point for writing from scratch, but it is far from an usable state and the license is not clear too...
So I'm now trying out jsonary (geraintluff/jsonary)  and I have the following questions:
1. The order of appearance of the JSON attributes is not defined. Is there a way via json-schema to enter such an order or do I have to add such an attribute to json schema (Maybe an attribute like visualApperance which can contain custom attributes or so??).
A short example to illustrate:
having the JSON data {a:1,b:2,c:3} does not guarantee that the order of rendering is  a b c especially if the data is {b:2, c:3, a:1}...
2. The order in array IS guaranteed, but at the moment there is no way to change the oder (i.e up, down action in basic renderer ), is this correct?
3. I have the need for a "visual readonly" attribute. Think of the _id attribute which is present for every json document in a mongodb collection. From the validation standpoint this is not a readonly attribute, since you must assign it when creating the json doc. But when displaying it in the GUI this is a readonly attribute. So for the json schema this is readonly: false but for the GUI it should be readonly: true...

So the main question is how to add additional attributes for the visual representation to json schema; Is this a good idea? Shall I invent some new attribute, like visualAppearance or should I create a second structure describing the visualAppearance on its own...

Any comments are welcome

Thanks
Ognian

Ognian

unread,
Mar 20, 2013, 9:06:35 AM3/20/13
to json-...@googlegroups.com
Wow, thank you both for the quick answers, that clarifies a lot.
Yes, adding displayOrder would be great. And since you answered it that quickly via both channels (groups and Github) we can continue via Github.
Jsonary looks really great.
 Ognian
Reply all
Reply to author
Forward
0 new messages