Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JSON have a schema?

Tags:

Do JSON / RESTful Web services have a schema equivalent to a wsdl?

If the answer is no, then how do two sides agree on a shared format?

If the answer is yes, are there any tools to auto generate JSON Java client/server from the schema?

like image 714
dov.amir Avatar asked Feb 15 '12 11:02

dov.amir


People also ask

Is there a JSON Schema?

JSON Schema is an IETF standard providing a format for what JSON data is required for a given application and how to interact with it. Applying such standards for a JSON document lets you enforce consistency and data validity across similar JSON data.

What is JSON Schema called?

JSON Schema is a specification for JSON based format for defining the structure of JSON data. It was written under IETF draft which expired in 2011. JSON Schema − Describes your existing data format. Clear, human- and machine-readable documentation.

How do I find my JSON Schema?

The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then use the IsValid(JToken, JsonSchema) method with the JSON Schema. To get validation error messages, use the IsValid(JToken, JsonSchema, IList<String> ) or Validate(JToken, JsonSchema, ValidationEventHandler) overloads.

How do I set a schema in JSON?

If you want to use a custom schema of your own that's part of your project, just click on your schema in Solution Explorer and then drag it to that dropdown list. Alternatively, you can use the $schema keyword in a JSON file to associate it with a schema.


2 Answers

JSON has a schema. REST services have WADL.

Also there are tools like wadl2java.

like image 176
Tomasz Nurkiewicz Avatar answered Nov 22 '22 23:11

Tomasz Nurkiewicz


I is possible to have a schema for restful web services and some tools support this. But it is common for restful web services to be published without the publishing organisation providing a machine readable schema.

Usually they provide some human readable documentation describing the structure of the JSON. The consumer writes a simple hand written library to consume it (much easer than it sounds in practice with modern tools) or the publisher provides a client library for users to use.

Also JSON/RESTfull web services tend to be carefully designed to deliver simple datastructers over the wire which are easy to consume. Do you need a schema for a list?

like image 28
Mark Avatar answered Nov 22 '22 23:11

Mark