Swiftpack.co -  g-mark/SwiftPath as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
JSONPath for Swift
.package(url: "https://github.com/g-mark/SwiftPath.git", from: "0.3.1")


Build Status Swift 4.2-5.3 compatible swift-package-manager CocoaPods compatible License: MIT

JSONPath for Swift


Somtimes, you don't want to hard-code the mapping from JSON to your model. You may want a generic way to model data from different sources. You may want to be able to update your remote data structure without having to update your app binary.


SwiftPath allows you to keep your data source and your data mapping dynamic.


SwiftPath is available through CocoaPods and Carthage.


pod "SwiftPath"


github "g-mark/SwiftPath" "master"


SwiftPath is a Swift implementation of JSONPath, which allows you to extract a subset of data from a larger chunk of JSON.

Sipmle usage


You can add a wildcard to objects to convert the current object to an array of it's values:

// Given:
  "books" : {
    "one" : { "title": "one" },
    "two" : { "title": "two" },
    "three" : { "title": "three" }

// When using this path:

// Then you'll get this output:
[ { "title": "one" }, { "title": "two" }, { "title": "three" } ]

Mapping properties

This is a difference from the JSONPath 'spec'. With SwiftPath, you can re-map property names to match your model in code. When collecting a subset of properties, you can do things like this (renamning the value property to id):

// Given:
  {"name": "one", "value": 1, "extra": true },
  {"name": "one", "value": 2, "extra": true },
  {"name": "one", "value": 3, "extra": true }

// When using this path:
$['name', 'value'=>'id']

// Then you'll get this output:
  {"name": "one", "id": 1 },
  {"name": "one", "id": 2 },
  {"name": "one", "id": 3 }


To publish a new version of SwiftPath:

  1. Update version number in SwiftPath.podspec
  2. Create a release branch off of production with version: e.g., release/#.#.#
  3. Merge develop into release/version branch
  4. Create PR into production from release/version branch
  5. Once CI passess, tag it with #.#.#, merge into production, and delete the release/version branch
  6. Run pod trunk push SwiftLint.podspec


Stars: 42
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Version 0.3.1
37 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API