Ramblings

August 15, 2010

JSON and xpath-like filtering

Filed under: Uncategorized — Tags: , , , — michaelangela @ 6:32 pm

I have been doing some recent work for a client with a large amount of JSON and webservices. Of course CharlesProxy is always helpful for this. I use it to be able analyze data flows, etc. In this case I wanted to be able to filter through the JSON to get at specific elements. Doing this for a while I thought it’d be neat to filter it the way we use XPath with XML. JSON Editor is a cool AIR app which allows you to view JSON and XML but also translate from one to the other. So I thought I’d just use that to convert the JSON to XML and then use XPath on it. Then I thought… “has anyone done anything like xpath for json?” Turns out they have.

jsonpath – Project Hosting on Google Code

JSONPath is a lightweight component that allows to find and extract relevant portions out of JSON structures on the client as well as on the server.

You can read more about it.

There are Wiki pages about usage and examples in Javascript and PHP.

Extensive test examples are available for JSONPath.

A PHP helper class JsonStore allows read, write and delete operations on JSON structures.

This isn’t the only json-xpath implementation of course. This also looks promising.

JPath – bluelinecity.com

JPath is a simple lightweight Javascript Class which provides an XPath-like querying ability to JSON objects.

Very cool.

Create a free website or blog at WordPress.com.