A library of JsonPath implicit convenience methods

Build Status Codacy Badge


A lib for adding implicit JsonPath functions to Strings

Based on https://github.com/gatling/jsonpath. I've embedded the code from gatling instead of adding the maven binary dependency in order to support more scala versions via cross compile.

See http://goessner.net/articles/JsonPath/ for jsonpath documentation.


  • ongoing dev is for for scala 2.12+
  • if you use scala 2.11 - use version 2.1.0
// https://mvnrepository.com/artifact/tech.navicore/navipath
libraryDependencies += "tech.navicore" %% "navipath" % "4.1.3"


See http://goessner.net/articles/JsonPath/ for JsonPath documentation.


Examples where "<json>" is a valid json string or parsed output from .asJson:

    import navicore.data.navipath.dsl.NaviPathSyntax._

First match support:

    val jsonString = """{"name": "Ishmael"}"""
    import navicore.data.navipath.dsl.NaviPathSyntax._
    val result = jsonString.query[String]("$.name")
    result should be ('defined)

Multiple matches support:

    val jsonString = """{"stuff": [{"name": "Ishmael"}, {"name": "Mud"}]}"""
    import navicore.data.navipath.dsl.NaviPathSyntax._
    val results = jsonString.query[List[String]]("$.stuff[*].name")
    results.fold()(r => assert(r.head == "Ishmael"))
    results.fold()(r => assert(r(1) == "Mud"))

Parse once, query many times support:

    val jsonString = """{"stuff": [{"name": "Ishmael", "id": 1}, {"name": "Mud", "id": 2}]}"""
    import navicore.data.navipath.dsl.NaviPathSyntax._
    val parsedJson = jsonString.asJson
    val names = parsedJson.query[List[String]]("$.stuff[*].name")
    val ids = parsedJson.query[List[Int]]("$.stuff[*].value")