JMESPath for Swift

Swift implementation of JMESPath, a query language for JSON.

Usage

Below is a simple example of usage.

import JMESPath

let expression = try Expression.compile("a.b")
let result = try expression.search(json: #"{"a": {"b": "hello"}}"#, as: String.self)
assert(String == "hello")

JMESPath will also use Mirror reflection to search objects already in memory

struct TestObject {
  struct TestSubObject {
      let b: [String]
  }
  let a: TestSubObject
}
let expression = try Expression.compile("a.b[1]")
let test = TestObject(a: .init(b: ["hello", "world!"]))
let result = try expression.search(test, as: String.self)
assert(result == "world!")

GitHub

https://github.com/adam-fowler/jmespath.swift