All Projects → adam-fowler → jmespath.swift

adam-fowler / jmespath.swift

Licence: Apache-2.0 license
Swift implementation of JMESPath, the JSON query language

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to jmespath.swift

restish
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Stars: ✭ 453 (+1462.07%)
Mutual labels:  jmespath
Httprunner
One-stop solution for HTTP(S) testing, written in Python.
Stars: ✭ 2,628 (+8962.07%)
Mutual labels:  jmespath
jmespath.rs
Rust implementation of JMESPath, a query language for JSON
Stars: ✭ 84 (+189.66%)
Mutual labels:  jmespath

JMESPath for Swift

Swift implementation of JMESPath, a query language for JSON. This package is fully compliant with the JMESPath Specification

Usage

Below is a simple example of usage.

import JMESPath

// compile query "a.b"
let expression = try JMESExpression.compile("a.b")
// use query to search json string
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
}
// compile query "a.b[1]"
let expression = try JMESExpression.compile("a.b[1]")
let test = TestObject(a: .init(b: ["hello", "world!"]))
// use query to search `test` object
let result = try expression.search(object: test, as: String.self)
assert(result == "world!")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].