restless-play-json


License

License

MIT
Categories

Categories

JSON Data
GroupId

GroupId

com.wellfactored
ArtifactId

ArtifactId

restless-play-json_2.11
Last Version

Last Version

0.5.1
Release Date

Release Date

Type

Type

jar
Description

Description

restless-play-json
restless-play-json
Project URL

Project URL

https://github.com/wellfactored/restless
Project Organization

Project Organization

com.wellfactored
Source Code Management

Source Code Management

http://github.com/wellfactored/restless

Download restless-play-json_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.wellfactored/restless-play-json_2.11/ -->
<dependency>
    <groupId>com.wellfactored</groupId>
    <artifactId>restless-play-json_2.11</artifactId>
    <version>0.5.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.wellfactored/restless-play-json_2.11/
implementation 'com.wellfactored:restless-play-json_2.11:0.5.1'
// https://jarcasting.com/artifacts/com.wellfactored/restless-play-json_2.11/
implementation ("com.wellfactored:restless-play-json_2.11:0.5.1")
'com.wellfactored:restless-play-json_2.11:jar:0.5.1'
<dependency org="com.wellfactored" name="restless-play-json_2.11" rev="0.5.1">
  <artifact name="restless-play-json_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.wellfactored', module='restless-play-json_2.11', version='0.5.1')
)
libraryDependencies += "com.wellfactored" % "restless-play-json_2.11" % "0.5.1"
[com.wellfactored/restless-play-json_2.11 "0.5.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.8
com.wellfactored : restless-core_2.11 jar 0.5.1
com.typesafe.play : play-json_2.11 jar 2.5.0

provided (2)

Group / Artifact Type Version
org.scoverage : scalac-scoverage-runtime_2.11 jar 1.1.1
org.scoverage : scalac-scoverage-plugin_2.11 jar 1.1.1

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 2.2.6

Project Modules

There are no modules declared in this project.

CircleCI Build Status Codacy Badge Maven Central

restless

Get less from your REST! A small scala/play library for filtering and projecting json results from REST calls

Getting started

In your build.sbt include:

libraryDependencies += "com.wellfactored" %% "restless" % "0.4.0"

Separate components

restless is implemented as restless-core and restless-play-json components. The core package implements the query parser that will generate an AST and play-json provides an implementation of an execution engine for the AST that applies it to documents made up of PlayFramework JsObjects. core depends only on Rob Norris (tpolecat)'s att-core library. restless-play-json will pull in com.typesafe.play-json and associated dependencies.

Query your REST results

restless implements a simple query language to filter lists of results. For example, of you had the following json output from your api call:

[
  {
    "foo" : "bar",
    "x" : 14
    "y" : 13
  },
  {
    "foo" : "baz",
    "x" : 14,
    "y" : 15
  }
]

The you could use a query such as foo = baz to filter this down to

[
  {
    "foo" : "baz",
    "x" : 14,
    "y" : 15
  }
]

or something a bit more complex like x > y. It also supports compound expressions such as:

  • a = b and c > 3
  • (a = b or c < 3) and d != "foo"

Numeric queries can include all the usual comparison operators, namely =, !=, <, >, <= and >=.

String comparisons are case-insensitive and can be one of:

  • =
  • !=
  • starts-with or starts with
  • ends-with or ends with
  • contains

Todo

There are still some arbitrary restrictions in the query syntax. For example, you cannot put a constant on the left-hand-side of a comparison at the moment.

Paths to string values can only be compared against string literals - it should be possible to compare them against other paths.

Thanks

Many thanks to Rob Norris (tpolecat) for the lovely atto parser and his help when I ran into some recursion issues. If you want a nice small, easy-to-use parser then check it out - https://github.com/tpolecat/atto

com.wellfactored

Well-Factored Software Ltd.

Versions

Version
0.5.1
0.5.0
0.4.0
0.3.0
0.2.0
0.1.7
0.1.6
0.1.5
0.1.4
0.1.2