From 02f1866e26194a7ad25169ca152e0f7fa21d3727 Mon Sep 17 00:00:00 2001 From: kallestenflo Date: Thu, 18 Sep 2014 22:38:59 +0200 Subject: [PATCH] Update README.md --- README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index da932337..1d20bd1a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ JSONPath **A Java DSL for reading JSON documents.** [![Build Status](https://travis-ci.org/jayway/JsonPath.svg?branch=master)](https://travis-ci.org/jayway/JsonPath) -[![Analytics](https://ga-beacon.appspot.com/UA-54945131-1/jsonpath/index)](https://github.com/igrigorik/ga-beacon) [read more](http://code.google.com/p/json-path/) @@ -97,16 +96,14 @@ Given the | `$..*` | Give me every thing you got | -Reading a JSON document ------------------------ +Reading a document +------------------ The simplest most straight forward way to use JsonPath is via the static convenience API. ```java - String json = "..."; List authors = JsonPath.read(json, "$.store.book[*].author"); - ``` If you only want to read once this is OK. In case you need to read an other path as well this is not the way @@ -114,18 +111,15 @@ to go since the document will be parsed every time you call JsonPath.read(...). parse the json first. ```java - String json = "..."; Object document = Configuration.defaultConfiguration().jsonProvider().parse(json); String author1 = JsonPath.read(document, "$.store.book[0].author"); String author2 = JsonPath.read(document, "$.store.book[1].author"); - ``` Personally I prefer the more flexible `ReadContext` API. ```java - String json = "..."; ReadContext ctx = JsonPath.parse(json); @@ -137,10 +131,10 @@ List> expensiveBooks = JsonPath .using(configuration) .parse(json) .read("$.store.book[?(@.price > 10)]", List.class); - ``` - +What is Returned When? +---------------------- PATH vs VALUE ------------- @@ -197,3 +191,5 @@ Gradle users ``` compile 'com.jayway.jsonpath:json-path:0.9.1' ``` + +[![Analytics](https://ga-beacon.appspot.com/UA-54945131-1/jsonpath/index)](https://github.com/igrigorik/ga-beacon)