Is there any naming convention for a json schema file extension? XML has .xsd (XML Schema Definition), what should json schema files have, .jsd (JSON Schema Definition)?
From Gary Court:
I personally use .schema.json, but there is no official file
extension. The official mime type however is
"application/schema+json".
Update 2022Nov
application/schema+json and application/schema-instance+json will be published by an IETF RFC.
According to current proposal, both json and schema.json extensions are supported. I still find it quite inconvenient for processing based on conventions to have a dot within an extension.
Previous comment
According to the last draft (v4), there is not a new extension proposed for files storing json-schemas. .json extension is used profusely within that document. .json is also the preferred extension in validators (PHP, Ruby, Python).
So I think that .json should be the preferred option in absence of an official/standard new extension.
From https://json-schema.org/understanding-json-schema/basics.html#id3
Since JSON Schema is itself JSON, it’s not always easy to tell when
something is JSON Schema or just an arbitrary chunk of JSON. The
$schema keyword is used to declare that something is JSON Schema. It’s
generally good practice to include it, though it is not required.
So you can use .json as the file extension for JSON schema but maybe with a $schema keyword (although optional) for better distinction.
I've started using .jschema after I had a run-in with an extension-based JSON Schema parser that automatically added id's to external RAML examples which are also .json files.
They are a specific format, after all. HTML is XML, which is UML, and we use a different file extension for each of those.
My suggestion is .jsd or .jsonsd standing for Json Schema Document.
I followed the way XML Schemas are named XSD (Xml Schema Document)
A JSON Schema is a valid JSON file so the extension .json is OK.
Then, the first attribute of your file should be '$schema' to declare the version of the specification you are using. Eg.
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
Related
Hei Guys,
I wonder if it is possible to edit jsons according to json schemas like settings.json in a ui form in vs code?
Can anyone tell if this is possible in vs code?
Yep! Although support for $schema in instance data isn't something that JSON Schema defines, it has become something of a convention.
VSCode supports declaring $schema in your data, and even supports relative paths.
In this example, my JSON data file Untitled-1.json is defined in the same folder as schema.json.
I need some guidance on how to proceed with a problem.
Our integration team receives xml files which are converted to json and sent to pub/sub. We then ingest the json files (or are supposed to) into bigquery.
The problem is that the xml files do not include all possible objects or values all the time. So, I cant create a correct schema in bq to receive the json files. I got the xsd file with an extension file which gives me all possible objects but I don't know how to convert this to a correct bq schema.
Do you have any suggestions on how to create a bq schema from xsd files? I was thinking that if I create an xml file with dummy data (including all objects and more than one object when creating repeated objects) with help of the xsd maybe that xml file may be converted to json and then use the auto-schema detection of bq.
Any suggestions?
Thanks,
Cris
If you have the XSD schema files, you can convert these to a valid JSON schema. There are a few tools that can help you to accomplish this.
Keep in mind that the tools are for general purposes and not for the particular case of BigQuery, so you'll have to tune the result to get a valid JSON schema. For this check the components of a BigQuery schema, and for quick reference the sample provided in the documentation.
I'm trying to define a coding standard for a project and I want to specify use of JSON Schema version 4.
However, from the offical JSON Schema website, if you follow the links for the Specifications, takes you to the github page, then into the Version 4 Draft at the IETF. This document explicitly states that it is an Internet-Draft document and says:
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
Since there don't seem to be any versions of the JSON Schema that are anything other than Internet-Draft status, how should I reference this?
Edit: This is in a written project document, not within a JSON file itself. I currently have text like this:
Python Standards and Style
All Python Source Files MUST be written in
Python 3.x, specifically targeting Python 3.5.1 as the default Python
3 installation with Ubuntu 16.04 LTS.
All Python Source Files MUST
conform to the PEP 8 standard [footnote:
https://www.python.org/dev/peps/pep-0008/ ].
All Python Source Files
MUST pass a flake8 [footnote:
https://pypi.python.org/pypi/flake8/3.2.1 ] check before each delivery.
The checker MUST be set up to be ultra-pedantic and it MUST be
considered a unit test failure if the checker needs to change anything
on the checked in Source Files.
All Python Source Files SHOULD use
Docstrings conforming to the PEP 257 standard [footnote:
https://www.python.org/dev/peps/pep-0257/ ].
JSON Standards and Style
All JSON Source Files MUST be written in JSON Schema version 4
[footnote: https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04 ].
All
JSON Source Files MUST conform to the Google JSON Style Guide 0.9
[footnote: https://google.github.io/styleguide/jsoncstyleguide.xml ]
All JSON Source Files MUST pass a jsonschema [footnote:
https://python-jsonschema.readthedocs.io/en ] check before each
delivery. The checker MUST be set up to be ultra-pedantic and it MUST
be considered a unit test failure if the checker needs to change
anything on the checked in Source Files.
TOML Standards and Style
All TOML Source Files MUST adhere to v0.4.0 of the TOML standard [footnote:
https://github.com/toml-lang/toml ].
All TOML Source Files MUST be loadable
with the pytoml parser v0.1.11 [footnote:
https://github.com/bryant/pytoml ], without error.
All TOML Source Files SHOULD be
aligned at the left margin – i.e. do not indent sub-sections.
To me, the italicised footnote to the JSON Schema reference would count as citing an Internet-Draft document, which is explicitly stated as not appropriate in the excerpt I gave above.
Since there don't seem to be any versions of the JSON Schema that are
anything other than Internet-Draft status, how should I reference
this?
You do this:
{
"$schema":"http://json-schema.org/draft-04/schema#",
... // the rest of your schema
}
Just because a standard is in draft format doesn't make it any less a standard.
Now, you also have the option of authoring the schema without a $schema declaration and it will still be perfectly valid. If you do this and use the proper JSON schema draft v4 definition then this will be usable by all parsers supporting draft v4. However, the convention is to use the $schema declaration.
All JSON Source Files MUST be written in JSON Schema version 4
You don't want all JSON files to be schema-based - that's ludicrous. However, any schema files you do need you will have no choice from a documentation perspective other than to reference a version of the standard. And that version should be draft 4 even though it's a draft.
The alternative is to completely remove any reference to JSON Schema altogether, which is probably the route I would take.
Does anyone known of a simple utility for editing a simple BSON database/file?
Did You try this: http://docs.mongodb.org/manual/reference/bsondump/ ?
The installation package that includes mongodump ('mongo-tools' on Ubuntu) should also include bsondump, for which the manpage says:
bsondump - examine BSON files in a human-readable form
You can convert BSON to JSON with the following:
bsondump --pretty <your_file.bson
As a data interchange format, BSON may not be suitable for editing directly. For manipulating a BSON dataset, you could, of course, upload it to MonogDB and work with that. Or, you could open the bsondump decoded JSON in an editor. But the BSON Wikipedia article indicates that compatible libraries exist in several languages, which suggests that you should also be able to decode it programmatically to an internal map representation and edit that internal representation in code.
Is there an existing program that helps forming a JSON Schema?
There's this great tool to get you started on generating a JSON Schema: http://www.jsonschema.net/ . Just feed a sample JSON files and out comes out a JSON Schema that you can then tweak.
Check this demo one. It is at an early stage but you can already edit jSON documents with a schema constraint as well as design a Schema itself.
And here is an official thread about Schema-based JSON editor:
You can use Orderly. They have DSL for schema description and you can try it online.
You could try this one (XML ValidatorBuddy) which is actually an XML editor but it also supports JSON and especially JSON Schema editing. The editor is a Windows desktop application and can do auto-completion and syntax-coloring for JSON schema files. You can also validate your JSON files against JSON schema.
You can do this in Liquid XML Studio, but its a commercial product
This isn't exactly something that'll help you with a 'schema', per se, but it's a visual way to navigate and manage JSON data.
http://braincast.nl/samples/jsoneditor/