Latest 1.1.0
License Apache License, Version 2.0
Platforms osx 10.11, ios 9.0, tvos 9.0, requires ARC

![MadeInSweden]( In-Stockholm, Sweden-blue.svg)
![Status]( doing well & alive-blue.svg)


![Platform]( + iOS + tvOS-blue.svg)
![Swift]( Version-3.0.1-blue.svg)
![TestCoverage]( Coverage-92.00%-blue.svg)

★ Give this repo a star and help its development grow! ★


Parse JSON data, simple, lightweight & without noise.

Enjoy the playground, it also contains some tests & an example json file.

Example Usage

// init with String, specifying single or double quotes
JSONX(with:"{'name':'Khan Solo'}", usesSingleQuotes:true)

// init with file path

// init with file URL

// init with Data

// init with Dictionary<String, Any>
JSONX(with:["name":"Khan-Solo", "level":50, "skills":[1,2,3], "droids":["shiny":9]])

Accessors Types

Supported Data Types: Bool, UInt,/Int, Float/Double, String, Array, Dictionary, Raw uncasted format

All accessor functions have the ability to define a default value:

// without default value
jsonx.asString("thisKeyDoesNotExist") // returns nil

// with default value
jsonx.asString("thisKeyDoesNotExist", default:"Default string") // returns "Default string"

Search using key paths:

    "parent": {
        "child": {
            "puppy": {
                "name": "voffy"
jsonx.asString(inKeyPath:"") // returns "voffy"

Simple JSON -> Swift Struct model mapping

    "Person": {
        "name": "Khan Solo",
        "age": 99
struct PersonModel
    var name:String?
    var age:Int?

    static func `init`(jsonx:JSONX)
    -> PersonModel
        var pm:PersonModel = PersonModel() = jsonx.asString("name", default:"Johnny Appleseed")
        pm.age = jsonx.asInt("age", default:0)

        return pm


Tailored for your Swifty needs!

Just type .as to see the function lookup with prefixed function names :-)


The provided XCTest measures the performance when it comes to finding a key in a hierarchy. Usually you would only do this once and cache the value, but it is interesting to see how JSONX compares to other alternatives. JSONX is actually so fast, you can use it in realtime without worrying about performance!

Tests were run on a MacBook Pro (Retina, 15-inch, Late 2013), 16 GB 1600 MHz DDR3, macOS 10.11.6 (15G1217)




The test measures each call 10000 times, lower result is better & faster.

JSONX 1.1 JAYSON 0.6.2 SwiftyJSON 3.1.4
Average Time Seconds: 0.078 0.163 1.097
Passed Time Seconds: 1.035 1.884 11.659

By average time JSONX is 2.08x faster than JAYSON and 14.06x faster than SwiftyJSON.

By passed time JSONX is 1.82x faster than JAYSON, and 11.26x faster than SwiftyJSON.


What’s New?

  • Version 1.1 improves performance as well as minor refactorings.


  • Swift Version 3.0.1
  • ARC
  • macOS 10.11 and later
  • iOS 9.0 and later
  • tvOS 9.0 and later

How to Install

There is no framework/library distibution, I recommend that you add the JSONX/Sources to your project. As this will allow you to easily find & read the JSONX API, it will also allow JSONX to compile using your apps build settings.

  • Git: run git clone then Drag & Drop the JSONX/Sources into your Xcode project.
  • Manual: Drag & Drop the JSONX/Sources into your Xcode project.
  • Carthage: In your Cartfile add github "MKGitHub/JSONX" ~> 1.1.0 then carthage update --no-build then Drag & Drop the JSONX/Sources into your Xcode project.
  • Swift Package Manager (still quite meaningless): run swift build or swift package generate-xcodeproj
  • CocoaPods (not recommended!): pod 'JSONX', '~> 1.1.0'


Go to the documentation index page.

Used In Apps

JSONX is used in production in the following apps/games (known to me), these apps are together used by many millions of users every day. Please let me know if you use JSONX.

  • McDonald’s Sweden
  • McDonald’s Switzerland


Copyright 2016 Mohsan Khan

Licensed under the Apache License, Version 2.0.

Latest podspec

    "name": "JSONX",
    "version": "1.1.0",
    "summary": "Parse JSON data, simple, lightweight & without noise.",
    "homepage": "",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE.txt"
    "authors": {
        "Mohsan Khan": "[email protected]"
    "platforms": {
        "osx": "10.11",
        "ios": "9.0",
        "tvos": "9.0"
    "source": {
        "git": "",
        "tag": "1.1.0"
    "source_files": "Sources/JSONX.swift",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This