Swiftpack.co -  illescasDaniel/DynamicJson as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
An enjoyable way to manage json objects in Swift
.package(url: "https://github.com/illescasDaniel/DynamicJson.git", from: "1.0.1")


Swift version Version license

An enjoyable way to manage json objects.


let json = """
  "name": "Daniel",
  "age": 22,
  "favouriteFoods": ["pizza"]

// Get a json from a raw string, from data or from an object (like a dictionary)
let danielJson = Json(raw: json)

// Get stuff
print(danielJson.name.string ?? "")
print(danielJson.favouriteFoods[0].string ?? "")

// You can also change the values inside
danielJson.favouriteFoods = ["hamburger", "you"]
print(danielJson.favouriteFoods.array ?? [])

Easily convert to a Codable object.

struct Person: Codable {
  let name: String
  let age: UInt
  var favouriteFoods: [String]

let daniel: Person? = danielJson.decoded()
print(daniel ?? "nope")

Fast Json traversal with NSDictionary#value(forKeyPath: String).

let otherJson = """
  "fullName": {
    "firstName": "Daniel",
    "lastName": "Illescas",
    "parent": {
      "fullName": {
        "firstName": "Peter",
        "lastName": "Illescas"
  "age": 22
let me = Json(raw: otherJson)
print(me[\.fullName.parent.fullName.firstName].string ?? "nope")
// or
print(me["fullName.parent.fullName.firstName"] ?? "nope")


Stars: 2
Last commit: 2 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.

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