We live in an API economy, surrounding ourselves with technologies built upon REST APIs. Social media, online shopping, internet banking, and Software as a Service all rely on exchanging data through REST API, and JSON is increasingly becoming the data format of choice.
Developers who interact with REST APIs can end up writing lots of code to navigate through JSON structures to find the data values they need. Making this code robust enough to deal with missing data or sophisticated enough to cross reference or aggregate data can require a developer to write hundreds of lines of code.
There has to be an easier way. With JSONata, there now is an easier way.
JSONata is to JSON what XPath is to XML. And, like the latest versions of XPath, it is much more than just a path navigation syntax. JSONata is a full-expression language with a rich complement of operators and functions, plus the ability to define your own functions. It also has the ability to build JSON output structures containing the results of your queries. In other words, it’s a transformation language.
Head over to http://ift.tt/2dGnU4B and see it in action. Type in the following JSONata expression:
$sum(Account.Order.Product.(Price * Quantity))
Order and Product are nested arrays. Each product has a price and a quantity and we want to multiply these together for each product within each order, then sum them up to calculate a total order price. In a single expression; no for-loops, ifs or buts. Go play.
The post Introducing JSONata: A query and transformation expression language for your JSON data appeared first on developerWorks Open.
Read the full article here by developerWorks Open