Giter Site home page Giter Site logo

play-jsonpath's Introduction

JSONPath library for Play

Join the chat at https://gitter.im/josephpconley/play-jsonpath

This library enables JSONPath queries on the Play JsValue.

Explanation of JSONPath can be found here: http://goessner.net/articles/JsonPath/

Releases

Here are the versions of this plugin compatible with the Play JSON library

Plugin version Play version Scala version
2.5.0 2.5.x 2.11.x
2.4.0 2.4.x [2.10.x, 2.11.x]
2.3.0 [2.2.x, 2.3.x] [2.10.x, 2.11.x]

Install

libraryDependencies += "com.josephpconley" %% "play-jsonpath" % "2.4.0"

Example Usage

val json = Json.parse("""
{
 "id": 1,
 "name": "Joe",
 "tags": ["programmer", "husband", "father", "golfer"],
 "address": [
    {"id": 2, "street": "123 Main St.", "city": "Springfield", "state": "PA"},
    {"id": 3, "street": "456 Main St.", "city": "Sea Isle City", "state": "NJ", "beach": true}
 ]
}
"""

import com.josephpconley.jsonpath.JSONPath

JSONPath.query("$.id", json)                    //JsNumber(1)
JSONPath.query("$..id", json)                   //JsArray(JsNumber(1), JsNumber(2), JsNumber(3))
JSONPath.query("$.address[*].city", json)       //JsArray(JsString("Springfield"), JsString("Sea Isle City"))
JSONPath.query("$.address[?(@.beach)]", json)   //JsArray(JsObject(Seq("id" -> JsNumber(3), "street" -> JsString("456 Main St."), "city" -> JsString("Sea Isle City"), "state" -> JsString("NJ"), "beach" -> JsBoolean(true)))

Blog post

You can read more about the library here

play-jsonpath's People

Contributors

danluszcz-pariveda avatar gitter-badger avatar josephpconley avatar shaagerup avatar valdemargr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.