JSON has become the language of the Web. Whether you’re working with web services or consuming sensor data, it’s likely that JSON is the preferred format for communication.
JSON is simple, easy to parse, and easy to view and understand. When working with and creating JSON one of the first questions encountered is “How do I know if my JSON is valid?”
Here we explore 3 options: (A) online JSON validators, (B) JSON validation libraries, and (C) a no-code solution.
Online JSON Validator – Option A
Perform a Google search and you’ll find many websites that assist in validating JSON.
They all work the same way. You paste JSON inside the browser, or specify the URL that returns JSON, and click ‘Validate’. You then get a reply indicating whether or not the JSON is valid. It’s quick, convenient, and something I regularly use.
Since JSONLint.com ranks first on Google, let’s use this one as a typical example of JSON validator websites.
To use you simply paste the JSON into the website and if the JSON is valid you get a message that says “Valid JSON”. If invalid then you get an error telling what is wrong with the JSON, where on the line the error is and a line number where the error is.
Interestingly there is also JSON Lint Pro. It too is free. It also goes beyond validation to give you the ability to “diff” two different JSON datasets.
JSON Validator Libraries – Option B
If you need to validate JSON as part of your application, then you need a JSON validation library in the language of your choice. Here is one such JSON Validator library I found on GitHub for Java: the JSON Schema Validator.
There are many such libraries. The JSON Schema website, has a list of 27 different options in a variety of different computer programming languages.
Validate JSON at an Enterprise Level – Option C
The reason we added JSON to our FME product was to let our users work with web services via a simple graphical interface. For example, Stewart recently blogged about using JSON and the Twitter Stream API to visualize tweets on Google Maps.
In adding JSON to FME, we immediately recognized that validation was a key component to our JSON capabilities. We also discovered that we occasionally received poorly formed JSON, and so we made it easy to catch this and take action.
If you’ve used FME, then you know that this is done with our JSONValidator transformer. It’s an extremely simple transformer. Data with JSON goes in. If it’s valid it goes out the “Passed” port, otherwise it goes out the “Failed” port. If the JSON has errors then you also get a list of all the errors that were found.
Additional Ways to Manipulate JSON
FME has hundreds of transformers, including several dedicated to JSON. Using these you can easily create, update, and parse JSON and make it easy for anyone to work with JSON. Of course we make it just as easy to parse XML.
Want to learn more? Join me on July 9th, as I host a webinar showing how to tackle 10 JSON challenges – including of course a JSON validator demo.
When you need to validate JSON, what tool do you typically use? Do you have any tips to share on JSON validation? Please share in the comments below.
Don MurrayDon is the co-founder and President of Safe Software. Safe Software was founded originally doing work for the BC Government on a project sharing spatial data with the forestry industry. During that project Don and other co-founder, Dale Lutz, realized the need for a data integration platform like FME. When Don’s not raving about how much he loves XML, you can find Don working with the team at Safe to take the FME product to the next level. You will also find him on the road talking with customers and partners to learn more about what new FME features they’d like to see.
There are also some desktop tools and (often XML) editors available to check the syntax of JSON. For example:
JSONBuddy (affordable and has also support for JSON Schema)
XML ValidatorBuddy (actually an enhanced version of JSONBuddy with additional XML functionalities)
XMLSpy (can also check JSON syntax)
Visual Studio 2013
(no direct links because I don’t know if they are supported here)
jsoneditor.org is also a free online tool to view, edit, format, validate and pretty print json. Please try it out.
Thanks for the comments guys. Please do feel free to put the links/url’s in so that we can point to them. I would also update the post to include links to other resources for JSON and XML validator technology
Another tool which can be used to validate JSON is
I am having a file of multiple JSON (Each JSON in a single line).Can you suggest me the easiest way to validate multiple jsons.
FME has a transformer that will automatically do this. Just add a JSON Reader to read in your source data, and send it through the JSONValidator – http://www.safe.com/transformers/json-validator/ Give it a shot and don’t hesitate to contact us on live chat if you need help.
Another great tool for JSON validator and treeview is http://jsontuneup.com
Hi All ,
Can anyone help me in comparing the excel data with Json.
thanks in advance.
We have a tutorial on Excel data to get you started: https://knowledge.safe.com/articles/29689/getting-started-with-excel-2.html Our support team will be happy to help you out with other transformations. Please send us a note on live chat: https://www.safe.com/live-chat/
Check this JSON Validator, formatter and tree viewer
Check this online JSON tool. https://onlinejsoneditor.com/
They provides 1) json formating 2) sharing json file online 3) making API request directly to your server 4) uploading big json file from your machine and many more.
Just loved this tool because everything is provided in one place.
Interesting article, thank you for sharing it. It’s a good approach for Excel and json conversion. I have found also this solution on the internet https://dev-bay.com/json-to-excel/ which also works good – but here one question about that, is it a good approach to flatter JSON like this tool does?
Great question. This really is the nugget of the hard issue when converting JSON to Excel. The answer of course is it depends. Sometimes the list or sub-object in JSON is restricted to a very small and known number of values. In that case flattening can work.
For the more general solution however you may want instead to create standalone JSON fragments which then you could convert to different excel files or different tabs in your excel file.
As you elude to Excel is inherently flat and JSON can have layers and layers of sub objects. With our technology you can do the mapping however you want thru its graphical interface but I wouldn’t say that this is always easy or there is an obvious way to map a complex JSON document to excel.