The Windward Studio

Windward Blog Home

JSON Basics: How to Query JSON Data

by
Posted on 03/22/2016

Please Share This

 

JSON Data LogoAre you building a template but don’t know how to query your JSON data? No problem. Gathering your JSON data is fairly simple as long as you understand a few JSONPath basics.

This blog post and video will help you understand how JSONPath works and how you can use Windward’s JSONPath tools to retrieve your JSON objects.

What is JSONPath?

JSONPath is a query language that enables you to select specific data from a JSON data file. JSONPath was originally modeled after the XPath query language, and those who know XPath can easily query their JSON data using slightly different syntax.

Okay, so what is JSON? JSON stands for JavaScript Object Notation. JSON is very popular and is formatted in a style that is JavaScript-friendly. Since most developers know JavaScript, JSON is meant to resemble JavaScript objects. This makes it easy for the JavaScript savvy to quickly read and manipulate data.

JSON is also made up of key-value pairs (called objects) in a .json file. Objects are contained in arrays and JSON can include many arrays of objects.

Additionally, JSON also makes it easy to share data between devices and different platforms much like XML. JSON is similar to XML (easily readable by both humans and machines), but the major difference is that JSON cannot be data typed like XML. XML can include schema files that allow you to define data types like integer, decimal, byte, etc. Stronger data types make it easier for developers when trying to accurately format or manipulate data.

Now that I’ve explained JSON, let’s get back to our topic. JSONPath is the language you would use to grab the data from the .json file you want to see or use.

Querying your JSON via JSONPath is really not that hard. If you know the basics of JSONPath, you can be as creative as you want when it comes to collecting and visualizing your data.

So How Do I Use JSONPath?

Instead of going on and on about how to use JSONPath, it’s probably better that I show you. I’ve created a short video that goes over the basics and gives examples on how to query data from a sample JSON file. Once you follow the easy steps in the video, you’ll be able to do just about anything with your JSON data.

Note: This video focuses on JSONPath (Goessner 0.8.0). Learning from the first version of JSONPath is a great way to get started using the query language. Also, in case you’re curious, http://www.jsonquerytool.com/ is the JSON query tool I’m using in the video. Windward now supports jayway/JsonPath 2.1.0.

Still Have Questions?

If you still have questions about how this works or thoughts to share on anything presented here, please let me know in the comments below.

Please Share This



Author: Dathan Ellis

Dathan used to be a software engineer but found that he loves working with people too. Now he uses his technical expertise to help clients build powerful custom applications in complex environments.

Other posts by