8 Great Tools For Working With JSON

JSONLint – Validate Your JSON

JSONLint is an online JSON validator and formatter. It will check your JSON for syntax errors and format it with proper indentation and line breaks to make it more human-readable (this can be very handy when analysing complex JSON documents). You can either paste your JSON data in the form or enter a URL and have JSONLint fetch it automatically.

Online JSON Editor

There’s a whole bunch of different JSON editors available, but JsonEditorOnline.org is easily the best one I’ve seen. It displays JSON as a hierarchical tree and lets you add, remove and duplicate fields, re-arrange them via drag & drop, change field type, and so on. The interface is intuitive and well thought out.

JSON Browser Add-ons

When you open a JSON document in the browser, most browsers will either offer to download the file or display it as plain text. To make working with JSON more convenient, you can install a JSON viewer add-on that will display JSON documents with syntax highlighting and proper indentation:

JSONH – Compress JSON

JSONH (“JSON Homogeneous Collections Compressor”) is a way to compress JSON documents that contain multiple items with the same keys. For example, it can take an array like this:

[{"a":"A","b":"B"}, {"a":"C","b":"D"}, {"a":"E","b":"F"}]

and pack it into this:

[2,"a","b","A","B","C","D","E","F"]

then unpack it into the original collection later.

Using compression saves bandwidth and can improve the performance of applications that download or send large amounts of JSON data. JSONH libraries are available for JavaScript, PHP, Python and Ruby.

JSON Schema – Document And Validate JSON

Have you ever wished JSON was more like XML? Probably not. But if you have – JSON Schema is for you. It lets you define the structure of your JSON document, specify validation rules, documentation, references (hyperlinks) and so on. Given a JSON document with a schema, you can then use a JSON validator like JSV to validate it. See also: JSON Schema validator for PHP.

JSONSelect – CSS-like Selectors For JSON

JSONSelect is a powerful CSS-like selector language for JSON documents. You can use it to extract information from complex JSON structures without having to explicitly navigate the object hierarchy. Here are a few example selectors to whet your appetite:

  • .foo .bar – select all nodes with the key bar that have an ancestor with the key foo.
  • .foo :last-child – select the last child node of the foo object.
  • :has(.lang:val("Spanish")) > .level – select the level node of all objects that contain a lang field with the value “Spanish”.
  • More examples are available on the project homepage.

jLinq – Query JSON

jLinq is a JavaScript library that lets you run complex queries on JSON arrays. It provides a fluent interface (like jQuery) that you can use to filter your data, extract the fields you need and sort the results. jLinq does have one drawback: the library hasn’t been updated in a while, and might no longer be maintained.

Underscore-CLI – Manipulate JSON On The Command-line

Underscore-CLI is the swiss-army knife of JSON processing. This command-line tool can do anything from basic pretty-printing to running arbitrary JavaScript or CoffeeScript. You can filter JSON documents, extract specific properties, apply arbitrary transformations to values (map/reduce/reduceRight), fill in missing properties with defaults, and much, much more. Underscore-CLI also supports the JSONSelect selector syntax mentioned above.

Related posts :

Leave a Reply