This project is read-only.

Choose JSON-Schema instead of automatical retrieving

Dec 11, 2014 at 3:30 PM
Right now it looks up a schema according to the JSON Datafile. (eg. "MyData.json" should be opened, then the error comes that the Program cannot find "MyData.schema.json").

It should be possible to be able to choose which File should be used as the Schema, and from which path. Like, "MyData.json" resides in "C:\", but "MyDataschema.schema.json" resides in "C:\Schema\MySchemas".
Dec 11, 2014 at 4:18 PM
Is it enough to show the file open dialog to select the schema?
Dec 11, 2014 at 4:58 PM
Edited Dec 11, 2014 at 4:59 PM
I'm planning to use JSON Schema draft v4 in the future... do you need support for the old standard? I'm currently implementing the reader and writer in this project https://github.com/rsuter/NJsonSchema
Dec 12, 2014 at 7:25 AM
Well, simply an open file dialog would work too, but I would have another Idea for that as well:

According to the draftv4 of JSON Schema, you can define "$schema" tags (containing an URI), and for the JSON Data containing Files, you can define "id"-Tags (containing an URI as well) which schema the JSON File should use. Now it would be a possibility to load a bunch of Schema- and Datafiles at once (through different dialogs, as an example), and the Datafiles find their correct Schema according to the "id"-Uri they have been provided with
Dec 12, 2014 at 7:37 AM
Also, the Editor should support "$ref" Schema Referencing for both local and online resources according to draftV4
Dec 12, 2014 at 7:38 AM
I think $id works together with $ref to "reuse" JSON blocks. I think its of no use for us. However the $schema field references the schema as uri, either we simply download this uri and/or build a directory to resolve a uri with local file mappings...

The problem is that the application uses the Json.NET library which only supports v3... I have to build v4 myself... But this is just a hobby project and proof of concept so I don't know when I have time for this.
Dec 12, 2014 at 7:40 AM
What are you u using this for?
Dec 12, 2014 at 7:43 AM
I am currently looking for Editors like this to check if my Datafiles are correct and fit their Schemas which are sometimes using "$ref"-References
Dec 12, 2014 at 7:49 AM
I'm using http://json.net/ for all the json parsing... It supports ref but only to reference parts of the document with an id, URLs or json paths are not supported... I think I cannot fix all these problems on my own... First I need to implement a draft v4 reader and validator...
Dec 12, 2014 at 7:51 AM
That's not the problem for me. I am referencing parts of the JSON Schemas as well, but that it'd work with URI's it would be needed to load all schemas needed at the same time.
Dec 12, 2014 at 7:53 AM
Are these web uris (i.e. http://) or local paths?
Dec 12, 2014 at 7:53 AM
Are these Uris only on the too object of the json data?
Dec 12, 2014 at 7:58 AM
Edited Dec 12, 2014 at 7:59 AM
No, they arent.
In a Schema-File, the id gets set right at the beginning:
{

"id": "https://example.org/my-schema",
"$schema": "http://json-schema.org/draft-04/schema#",
.....

}
and in the Datafile, they are getting referenced like this:
"myReference": {
"type": "object",
"$ref": "https://example.org/my-schema#"
}
But there are also cases where I define only to choose certain objects out of the Schema:

Schema:
{

"id": "https://example.org/my-schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"myObject":{...}
.....

}

Datafile:

"myRefObject": {
"type": "object",
"$ref": "https://example.org/my-schema#myObject"
}
Dec 12, 2014 at 8:10 AM
Are you sure that you are using $ref correctly? I think its an include not a schema reference... see http://json-schema.org/example2.html

I think if you have this schema
{

"id": "https://example.org/my-schema",
"$schema": "http://json-schema.org/draft-04/schema#",
.....

}
you can define your data json like this
"myReference": {
"type": "object",
"$schema": "https://example.org/my-schema#"
}
a $ref would just "copy" the whole schema into the myReference object
Dec 12, 2014 at 8:11 AM
I am using it correctly, because thats exactly what I want.

I have like, a "Task"-schema, and a "MetaData"-Schema. The whole "MetaData"-Schema has to be referenced in a "MetaData"-Object in the "Task"-Schema
Dec 12, 2014 at 8:17 AM
Ah ok :-), sorry.

So myReference is a property with the schema imported using the $ref property?

I think you should use another tool if its only for validating your files. The $id and $ref properties are handled by the underlying library which i'm not planning to replace, i'm just thinking about reimplementing the JSON schema reading/validating to support v4... But this will take some time and the $ref/$id problems are not solved then... Maybe we have to push the Json.NET team to implement it the right way (currently $ref can only reference blocks with an $id tag in the same document and only if the block is before the $ref property).
Dec 12, 2014 at 8:20 AM
I am currently validating my Schemas to my Datafiles via my own implementation of a validator using npm and the "TV4"-Package. I simply need an Editor to edit JSON-Datafiles and Schemas right now, and yours seemed perfect to me as it doesnt allow the user to change the structure of the Datafile as it refers to the schema all the time
Dec 12, 2014 at 8:35 AM
There is a lot of effort needed to support all aspects of json schema v4 as currently only a small part is implemented (eg inheritance is missing). The idea was to try to implement something for this http://blog.rsuter.com/?p=795 scenario... I have to work for my real job now :)
Dec 30, 2014 at 9:06 PM
Hi, i've updated the application. It is now using another library and supports JSON schema v4...