{"id":18281940,"url":"https://github.com/tyrone-sudeium/jsoncore","last_synced_at":"2025-04-05T06:30:42.649Z","repository":{"id":142705605,"uuid":"44814617","full_name":"tyrone-sudeium/JSONCore","owner":"tyrone-sudeium","description":"A Swift JSON parser that doesn't need Objective-C bridging and doesn't depend on Foundation","archived":false,"fork":false,"pushed_at":"2017-06-08T04:35:03.000Z","size":191,"stargazers_count":83,"open_issues_count":1,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-20T23:33:51.510Z","etag":null,"topics":["json-parser","server-side-swift","swift","swift-package-manager","zero-dependency"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tyrone-sudeium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-23T13:25:16.000Z","updated_at":"2023-04-30T23:51:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddbf6cda-f56f-4e80-84c7-6cfcbb69ed5f","html_url":"https://github.com/tyrone-sudeium/JSONCore","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyrone-sudeium%2FJSONCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyrone-sudeium%2FJSONCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyrone-sudeium%2FJSONCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyrone-sudeium%2FJSONCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyrone-sudeium","download_url":"https://codeload.github.com/tyrone-sudeium/JSONCore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299766,"owners_count":20916183,"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":["json-parser","server-side-swift","swift","swift-package-manager","zero-dependency"],"created_at":"2024-11-05T13:03:46.133Z","updated_at":"2025-04-05T06:30:42.643Z","avatar_url":"https://github.com/tyrone-sudeium.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Core\n\n[![Build Status](https://travis-ci.org/tyrone-sudeium/JSONCore.svg)](https://travis-ci.org/tyrone-sudeium/JSONCore)\n\n## Project Discontinued!\n\nWell everyone, it was fun while it lasted! As of Swift 4, the JSON situation\nis vastly improved, and there's very little practical reason to use JSONCore\nany more! Please adopt the official Swift `Codable` protocol and use the\nbuilt-in encoder and decoder.\n\nSee the Apple documentation of [Codable](https://developer.apple.com/documentation/swift/codable) \nfor more information.\n\nJSONCore will not be updated for Swift 4 and it will not receive any future\ndevelopment.\n\n## Introduction\n\nJSON Core is a JSON parser and serializer written using only core Swift. This\nmeans it has no dependencies on Foundation, UIKit, AppKit or even Darwin. This\nis a true parser and serializer, it doesn't use `NSJSONSerialization` at all,\nnor does it call out to any C JSON library.\n\nIt requires at least Xcode 8 and Swift 3. If you need Swift 2.x support, use\nthe 1.0.0 tag.\n\n## Why?\n\n### Performance\nThe Swift - Objective-C bridge is very efficient for the most part. However,\nwhen dealing with potentially millions of object allocations, passing them back\nand forth through the bridge is extremely costly. This is completely unnecessary\nbusywork for the CPU and is just a side effect of the fact that the standard\nJSON engine for Swift today is an Objective-C class, `NSJSONSerialization`,\nwhich returns Objective-C objects.\n\nJSON Core works only on native Swift types, `Array`, `Dictionary`, `Int64`,\n`Double`, and `Bool`, which means there's no bridging required. It's still a\nlong way off being as efficient as `NSJSONSerialization` in Objective-C only\nmode, but it's already considerably faster than `NSJSONSerialization` when used\nwith Swift code.\n\nHere's a chart showing the performance characteristics of JSON Core when parsing\nan extremely large JSON file from disk. The source JSON file is generated when\nrunning the unit test and contains an array of one million JSON objects. The\nfile is approximately 212MB.\n\n![Chart](/Images/Chart.png)\n\nOver time I'd like to improve this but at the moment I'm limited mostly by the\nperformance of `Dictionary`. It's extremely costly to build up a `Dictionary` by\ncreating an empty one and then setting values and keys manually, but as of\nSwift 2.1, there's no other way to create a `Dictionary` dynamically. In\nFoundation / CoreFoundation it's possible to very quickly create an\n`NSDictionary` using a C array of values and keys. Unless I write my own data\nstructure to represent JSON objects, which means giving up the advantages of\nsimply returning a Swift `Dictionary` to the caller, I'm probably not going to\nget a huge amount more performance.\n\nBe aware that if the string you pass in to `JSONParser.parseData` was bridged\nusing an `NSString` constructor, there'll be serious performance ramifications.\nYou should be aware of what's constructing your raw JSON data object and how\nit gets initialised. You'll get an almost 2x speed boost by sticking to `String`\nover `NSString`.\n\n## Usage\n```Swift\nlet json = \"{\\\"test\\\": 1}\"\ndo {\n    let value = try JSONParser.parse(string: json)\n    // value is a JSONValue enum, which for our JSON should be\n    // an Object/Dictionary\n    guard let test = value[\"test\"]?.int else { return }\n    print(\"test is \\(test)\")\n} catch let err {\n    if let printableError = err as? CustomStringConvertible {\n        print(\"JSON parse error: \\(printableError)\")\n    }\n}\n```\n\n## Installation\n\n###via Swift Package Manager (Swift 3)\nTo use JSONCore as a Swift Package Manager package just add the following in\nyour `Package.swift` file.\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"HelloWorld\",\n    dependencies: [\n        .Package(url: \"https://github.com/tyrone-sudeium/JSONCore.git\", majorVersion: 2))\n    ]\n)\n```\n\n###via Carthage\nTo use JSONCore with Carthage add \nYou can use [Carthage](https://github.com/Carthage/Carthage) to install JSONCore\nadd the following lines to your Carthage:\n\n```\ngithub \"tyrone-sudeium/JSONCore\"\n```\n\n###via Cocoapods\nI'm not on CocoaPods (yet!), however, I will add support for CocoaPods \nwhen I'm happy JSON Core is stable enough for production use.\n\n###Manual\nJSON Core is just a single Swift file with zero dependencies, so feel free to\nmake this repo a submodule and just drop the `JSONCore.swift` file into your\nproject directly.\n\n## Other JSON Libraries\nIf you hate something, or everything about JSON Core, the Swift community\nhas you covered with plenty of alternatives.\n\nJust want the fastest parser around?\n* [vdka's JSON](https://github.com/vdka/JSON)\n\nWant something quick but also does interesting things like lazy sequences?\n* [PMJSON](https://github.com/postmates/PMJSON)\n* [Jay](https://github.com/DanToml/Jay)\n\nJust want something popular?\n* [Argo](https://github.com/thoughtbot/Argo) (note: uses `NSJSONSerialization`)\n* [Freddy](https://github.com/bignerdranch/Freddy)\n\nI won't take it personally.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyrone-sudeium%2Fjsoncore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyrone-sudeium%2Fjsoncore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyrone-sudeium%2Fjsoncore/lists"}