{"id":21189012,"url":"https://github.com/mkgithub/jsonx","last_synced_at":"2025-07-10T02:31:28.871Z","repository":{"id":56916556,"uuid":"71016003","full_name":"MKGitHub/JSONX","owner":"MKGitHub","description":"Parse JSON data, simple, lightweight \u0026 without noise.","archived":false,"fork":false,"pushed_at":"2018-10-17T21:01:31.000Z","size":465,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T17:15:26.676Z","etag":null,"topics":["fast","jayson","json","jsonx","performance","swift","swiftyjson"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MKGitHub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-15T22:04:39.000Z","updated_at":"2018-10-17T21:01:33.000Z","dependencies_parsed_at":"2022-08-21T03:50:52.134Z","dependency_job_id":null,"html_url":"https://github.com/MKGitHub/JSONX","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MKGitHub%2FJSONX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MKGitHub%2FJSONX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MKGitHub%2FJSONX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MKGitHub%2FJSONX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MKGitHub","download_url":"https://codeload.github.com/MKGitHub/JSONX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225614626,"owners_count":17496938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast","jayson","json","jsonx","performance","swift","swiftyjson"],"created_at":"2024-11-20T18:49:32.818Z","updated_at":"2024-11-20T18:49:33.807Z","avatar_url":"https://github.com/MKGitHub.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MadeInSweden](https://img.shields.io/badge/Made_In-Stockholm_Sweden-blue.svg)](https://en.wikipedia.org/wiki/Stockholm)\n[![Status](https://img.shields.io/badge/Status-Active_and_in_development-blue.svg)](https://github.com/MKGitHub/JSONX)\n\n[![Version](https://img.shields.io/badge/Version-1.3-blue.svg)](https://github.com/MKGitHub/JSONX)\n[![Carthage](https://img.shields.io/badge/carthage-1.3-blue.svg)](https://github.com/MKGitHub/JSONX)\n[![SPM](https://img.shields.io/badge/SPM-1.3-blue.svg)](https://github.com/MKGitHub/JSONX)\n[![CocoaPods](https://img.shields.io/badge/CocoaPods-🤬-blue.svg)](https://github.com/MKGitHub/JSONX)\n\n[![Platform](https://img.shields.io/badge/Platforms-macOS_iOS_tvOS-blue.svg)](https://github.com/MKGitHub/JSONX)\n[![Swift](https://img.shields.io/badge/Swift_Version-4.2-blue.svg)](https://github.com/MKGitHub/JSONX)\n[![TestCoverage](https://img.shields.io/badge/Test_Coverage-98.32％-blue.svg)](https://github.com/MKGitHub/JSONX)\n\n\n🌟 Give this repo a star and help its development grow! 🌟\n\n\n![JSONX Logo](https://github.com/MKGitHub/JSONX/blob/master/Images/Banner.png)\n\nParse JSON data, simple, lightweight \u0026 without [noise](https://github.com/SwiftyJSON/SwiftyJSON/issues).\n\nEnjoy the playground, it also contains some tests \u0026 an example JSON file.\n\n\u003cbr/\u003e\n\n\nExample Usage\n------\n```swift\n// init with a `String`\nJSONX(string:\"{'name':'Khan Solo'}\", usesSingleQuotes:true)\n\n// init with a file path\nJSONX(filepath:path)\n\n// init with a file `URL`\nJSONX(url:url)\n\n// init with `Data`\nJSONX(data:data)\n\n// init with a `Dictionary`\nJSONX(dictionary:[\"name\":\"Khan-Solo\", \"level\":50, \"skills\":[1,2,3], \"droids\":[\"shiny\":9]])\n\n// convert dictionary to `JSONX`\nlet dict = [\"key1\":\"value1\", \"key2\":\"value2\"]\nlet jsonX = dict.toJSONX(context:\"converting stuff\")\n```\n\n\u003cbr/\u003e\n\n\nAccessors Types\n------\n**Supported Data Types:**\n\nBool, UInt/Int, Float/Double, String, Array, Dictionary, Raw uncasted format\n\n**Default Values:**\n\nAll accessor functions have the ability to define a default value:\n\n```swift\n// without default value\njsonx.asString(\"thisKeyDoesNotExist\")  // returns nil\n\n// with default value\njsonx.asString(\"thisKeyDoesNotExist\", default:\"Default string\")  // returns \"Default string\" 🤩\n```\n\n**Search using Key Paths:**\n\n```swift\n{\n    \"parent\": {\n        \"child\": {\n            \"puppy\": {\n                \"name\": \"voffy\"\n            }\n        }\n    }\n}\n\njsonx.asString(inKeyPath:\"parent.child.puppy.name\")  // returns \"voffy\" 🤩\n```\n\n\u003cbr/\u003e\n\n\nModel Mapping: JSON → Swift Struct\n------\n```swift\n// example\n{\n    \"Person\": {\n        \"name\": \"Khan Solo\",\n        \"age\": 99\n    }\n}\n\n// example\nstruct PersonModel\n{\n    var name:String!\n    var age:Int!\n\n    static func `init`(jsonx:JSONX) -\u003e PersonModel\n    {\n        var pm = PersonModel()\n\n        pm.name = jsonx.asString(\"name\", default:\"John Doe\")\n        pm.age = jsonx.asInt(\"age\", default:0)\n\n        return pm\n    }\n}\n\nPersonModel.init(jsonx:myJSONXObject)\n```\n\n\u003cbr/\u003e\n\n\nTailored for your Swifty needs!\n------\nJust type **.as** to see the function lookup with prefixed function names 😍\n\n![asLookup](https://github.com/MKGitHub/JSONX/blob/master/Images/asLookup.png)\n\n\u003cbr/\u003e\n\n\nPerformance\n------\nThe 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 fast, you can use it in realtime without worrying about performance!\n\n```text\n    jsonx.asString(inKeyPath:\"key1.key2.key3.key4.key5\")    // much nicer syntax 😍\n\nswiftyjson[\"key1\"][\"key2\"][\"key3\"][\"key4\"][\"key5\"].string\n```\n\nThe test measures each call 10000 times, lower result is better \u0026 faster.\n\n![asLookup](https://github.com/MKGitHub/JSONX/blob/master/Images/Performance.png)\n\n\u003cbr/\u003e\n\n\nWhat’s New?\n------\n* Version 1.3 updates for Swift 4.2.\n  * Added `dictionary.toJSONX(:)` function which creates a JSONX object from a dictionary.\n  * Updated documentation + comments.\n* Version 1.2.2 bug fix for null values, bug fix for non-existing key in dictionary key path crash.\n* Version 1.2.1 adds support for Swift 4 and Xcode 9.\n* Version 1.2.0 adds support for Swift 4 and Xcode 9.\n* Version 1.1.0 improves performance as well as minor refactorings (Swift 3.0.1/3.1/3.2).\n\n\nRequirements\n------\n* Swift Version 4.2\n* Xcode 10\n\n\nHow to Install\n------\nThere is no framework/library distibution, I recommend that you simply add the `JSONX.swift` to your project. As this will allow you to easily find \u0026 read the JSONX API, and it will also allow JSONX to compile using your apps build settings. \n\n* Using Git: `git clone https://github.com/MKGitHub/JSONX.git` then add `JSONX.swift` to your Xcode project.\n* Manual Way: Add `JSONX.swift` to your Xcode project.\n* Using Carthage: In your Cartfile add `github \"MKGitHub/JSONX\" ~\u003e 1.3` then `carthage update --no-build` then add `JSONX.swift` to your Xcode project.\n* Using Swift Package Manager: swift-tools-version:4.0\n* CocoaPods support has been removed! 🙌🙏🎉 Never use CocoaPods! 💀\n\n\nDocumentation\n------\nGo to the documentation [index page](http://htmlpreview.github.io/?https://raw.githubusercontent.com/MKGitHub/JSONX/master/docs/index.html).\n\n\nUsed In Apps\n------\nJSONX is used in production in the following apps/games (that I'm aware of), these apps are together used by millions of users. Please let me know if you use JSONX.\n\n* Hoppa\n* McDonald's apps\n* Lånekoll\n\n\nNotes\n------\nhttps://github.com/MKGitHub/JSONX\n\nhttp://www.xybernic.com\n\nCopyright 2016/2017/2018 Mohsan Khan\n\nLicensed under the Apache License, Version 2.0.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkgithub%2Fjsonx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkgithub%2Fjsonx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkgithub%2Fjsonx/lists"}