admin / 09.06.2018

Best Online JSON Validator — JSON Lint Tool to validate JSON data

JSON Validator

Validates a JSON string against RFC 4627 (The application/json media type for JavaScript Object Notation) and against the JavaScript language specification. You can configure the validator to be lenient or strict.

*The maximum size limit for file upload is 2 megabytes.

If you want to learn more about JSON, jump to the JSON Explained section of this page.

JSON Explained

What is JSON?

JSON stands for «JavaScript Object Notation» and is pronounced «Jason» (like in the Friday the 13th movies).

Антананариву

It’s meant to be a human-readable and compact solution to represent a complex data structure and facilitate data-interchange between systems.

Why use JSON?

There are tons of reasons why you would want to use JSON:

  • It’s human readable… if it’s properly formatted 😛
  • It’s compact because it doesn’t use a full markup structure, unlike XML
  • It’s easy to parse, especially in JavaScript
  • A gazillion JSON libraries are available for most programming languages
  • The data structure is easy to understand

The JSON format

There are just a few rules that you need to remember:

  • Objects are encapsulated within opening and closing brackets { }
  • An empty object can be represented by { }
  • Arrays are encapsulated within opening and closing square brackets [ ]
  • An empty array can be represented by [ ]
  • A member is represented by a key-value pair
  • The key of a member should be contained in double quotes. (JavaScript does not require this. JavaScript and some parsers will tolerate single-quotes)
  • Each member should have a unique key within an object structure
  • The value of a member must be contained in double quotes if it’s a string (JavaScript and some parsers will tolerates single-quotes)
  • Boolean values are represented using the true or false literals in lower case
  • Number values are represented using double-precision floating-point format. Scientific notation is supported
  • Numbers should not have leading zeroes
  • «Offensive» characters in a string need to be escaped using the backslash character
  • Null values are represented by the null literal in lower case
  • Other object types, such as dates, are not properly supported and should be converted to strings. It becomes the responsibility of the parser/client to manage this
  • Each member of an object or each array value must be followed by a comma if it’s not the last one
  • The common extension for json files is ‘.json’
  • The mime type for json files is ‘application/json’

Example:

JSON in JavaScript

Because JSON derives from JavaScript, you can parse a JSON string simply by invoking the eval() function. The JSON string needs to be wrapped by parenthesis, else it will not work! This is the #1 problem when programmers first start to manipulate JSON strings. That being said, DON’T do this!

Example using the ‘dangerous’ eval():

As pointed out by M. Clement at Inimino, a better and more secure way of parsing a JSON string is to make use of JSON.parse(). The eval() function leaves the door open to all JS expressions potentially creating side effects or security issues, whereas JSON.parse() limits itself to just parsing JSON. JSON.parse() is available natively in most recent browsers. If you need to support older browser, make use of an external JavaScript library such as Douglas Crockford’s json2.js.

Example using JSON.parse():

If you want to create a JSON string representation of your JavaScript object, make use of the JSON.stringify() function.

Example using JSON.stringify():

You can also create JavaScript objects using the JSON syntax directly in your code.

Example of creating a JavaScript object using ‘JSON’ syntax:

Programming languages and JSON

The website JSON.org maintains an extensive list of JSON libraries and they are categorized in programming languages. Unfortunately, there are so many libraries out there that it’s very hard to chose one! Note that VERY few JSON libraries have strict adherence to the JSON specification and this can lead to parsing problems between systems.

These are my recommended JSON libraries:

Other useful JSON resources

  • JSON.org — Excellent overall explanation and list of many JSON libraries
  • Wikipedia — Brief explanation of JSON
  • TheServerSide.net — A list of JSON resource guide on TheServerSide.com

© FreeFormatter.com — FREEFORMATTER is a d/b/a of 10174785 Canada Inc. — Copyright Notice — Privacy Statement — Terms of Use

JSON Schema definitions, JSON content, and referenced schema definitions can be entered, or pasted into, their corresponding text areas. Up to 8 JSON Schema Reference ($ref) definitions can be loaded (use the tabs 1 to 8 to navigate between each).

The Validate button runs the schema validator and displays the validation result in the Results text area. If any of the content is invalid, its text area will be bordered in red.

For the reference schemas, the tabs corresponding to any invalid content will also be bordered in red.

To reset all entry areas press the Reset All button.

Pre-defined content is provided through a catalog of examples to work with.

antananarivo — профиль | СПЛЕТНИК

These are available using Import at the top right. The Import window shows the catalog contents. Select the item to work with from the Items selection list and press the Load button. The Import window is modeless, it can be left open while working with the content if desired.


Questions or comments can be sent to usingjsonschema@yahoo.com or posted on the issues tracker for the project at GitHub.

JSON Schema provides data definition for JSON content. It can be used to enable validation of content against the schema, or for tools / applications to generate or manipulate content with guidance from the constraints defined by the schema.

The specification of JSON Schema is managed through the IETF, in the following draft specifications (version 4),

The following resources are available,

There are JSON Schema validation libraries for a wide variety of programming languages and runtime platforms. See the Software page on the JSON Schema home site for a list.

The current version is draft-07!

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents.

Advantages

JSON Schema

  • describes your existing data format
  • clear, human- and machine-readable documentation
  • complete structural validation, useful for
    • automated testing
    • validating client-submitted data

JSON Hyper-Schema

  • make any JSON format a hypermedia format — no constraints on document structure
  • use URI Templates with instance data
  • describe client data for use with links using JSON Schema
  • recognize collections and collection items

Project Status

The JSON Schema project intends to shepherd the Core, Validation, and Hyper-Schema specifications to RFC status. Currently, we are continuing to improve our self-published Internet-Drafts. The next step will be to get the drafts adopted by an IETF Working Group.

In the meantime, publication of Internet-Draft documents can be tracked through the IETF:

Internet-Drafts expire after six months, so our goal is to publish often enough to always have a set of unexpired drafts available.

Antananarivo

There may be brief gaps as we wrap up each draft and finalize the text.

The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from draft to draft. However, these are still drafts, and given a clear enough need validated with the user community, major changes can occur.

Progress on the next set of Internet-Drafts can be tracked on GitHub. The draft-08 milestone will track the evolving scope of the draft

Quickstart

The JSON document being validated or described we call the instance, and the document containing the description is called the schema.

The most basic schema is a blank JSON object, which constrains nothing, allows anything, and describes nothing:

You can apply constraints on an instance by adding validation keywords to the schema. For example, the “type” keyword can be used to restrict an instance to an object, array, string, number, boolean, or null:

JSON Schema is hypermedia ready, and ideal for annotating your existing JSON-based HTTP API. JSON Schema documents are identified by URIs, which can be used in HTTP Link headers, and inside JSON Schema documents to allow recursive definitions.

More

Interested? Check out:

We encourage updating to the latest specification, as described by the draft-07 meta-schemas. However, if you are still using draft-04, you may be interested in:

Questions? Feeling helpful? Get involved on:

FILED UNDER : IT

Submit a Comment

Must be required * marked fields.

:*
:*