{"id":15293588,"url":"https://github.com/julianalonso/jasoon","last_synced_at":"2026-05-04T03:36:45.438Z","repository":{"id":56915660,"uuid":"85899060","full_name":"JulianAlonso/JASOON","owner":"JulianAlonso","description":"Swift JSON parsing library","archived":false,"fork":false,"pushed_at":"2018-09-04T20:30:55.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T14:15:58.868Z","etag":null,"topics":["json","json-parser","parsing","parsing-library","swift","swift3"],"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/JulianAlonso.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}},"created_at":"2017-03-23T02:42:30.000Z","updated_at":"2020-03-18T11:58:35.000Z","dependencies_parsed_at":"2022-08-20T20:50:38.364Z","dependency_job_id":null,"html_url":"https://github.com/JulianAlonso/JASOON","commit_stats":null,"previous_names":["julianalonso/jason"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulianAlonso%2FJASOON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulianAlonso%2FJASOON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulianAlonso%2FJASOON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulianAlonso%2FJASOON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JulianAlonso","download_url":"https://codeload.github.com/JulianAlonso/JASOON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245294768,"owners_count":20591909,"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","json-parser","parsing","parsing-library","swift","swift3"],"created_at":"2024-09-30T16:50:08.335Z","updated_at":"2025-12-26T09:01:55.893Z","avatar_url":"https://github.com/JulianAlonso.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JASOON\n\n\u003c!-- [![CI Status](http://img.shields.io/travis/julianAlonso/JASON.svg?style=flat)](https://travis-ci.org/julianAlonso/JASON) --\u003e\n[![Version](https://img.shields.io/cocoapods/v/JASON.svg?style=flat)](http://cocoapods.org/pods/JASON)\n[![License](https://img.shields.io/cocoapods/l/JASON.svg?style=flat)](http://cocoapods.org/pods/JASON)\n\u003c!-- [![Platform](https://img.shields.io/cocoapods/p/JASON.svg?style=flat)](http://cocoapods.org/pods/JASON) --\u003e\n\n## What?\nSo simple, library to parse JSON Objects.\n\n## Where is the value?\n\nProvide very useful errors, with them you will know what value is missing and from where. If you are parsing some property to one object wich property is not optional, the error will tell you what property is and what object. Forgot spend time debugging to find out the error.\nAlso will tell you if the error is a type error. If you are parsing a string to int, it will fail and also will tell you where and why.\nDebugging JSON parsing never has been so easy.\n\n### Really simple to use.\n\nTo make objects created by json you only need implement `ExpressibleByJSON` like this:\n```\nstruct Person {\n  let name: String\n  let age:  Int\n}\nextension Person: ExpressibleByJSON {\n  init(_ json: JSON) throws {\n    self.name = try json \u003c\u003c\u003c \"name\"\n    self.age  = try json \u003c\u003c\u003c \"age\"\n  }\n}\n```\n\nThen create the object:\n```\n  session.dataTaskWithRequest(someRequest) { data, response, error in\n    if let data = data {\n      do {\n        let json = try JSON(data)\n        let person = try Person(json)\n      } catch {\n        //Elevate error...\n      }\n    }\n  }\n```\n\n\n## Forgot optional types.\n\nYes, right now, you can forgot parsing json like this:\n\n```swift\n\n  if let string = json[\"string\"] as? String {\n    //Do something...\n  }\n\n```\n\nJASON works with operators, `\u003c\u003c\u003c` for all types and `\u003c\u003c\u003c?` for optional types.\nThe usage its simply, get the JSON object (provided by JASON), and get fields.\n\nIf you want a string:\n`let string = try json \u003c\u003c\u003c \"name\" as String`, (if the type is previus declarated like in classes or structs, you dont need the as keyword `self.name = try json \u003c\u003c\u003c \"name\"`)\n\nAnd optional types are the same, but using the optional operator that not throws an error.\n`let optionalString: String? = json \u003c\u003c\u003c? \"name\"`\n\nJASON also will infer types for us, any type that implements `ExpressibleByJSON` or `ConvertibleFromJSON` can be parsed, by this way, all the types that you want can be parsed.\nThis allow us to have nested types, parse arrays and dictionarys in the most simple way possible and of course, on failing cases will provide us **very useful debug info**\n\n**¿Why throwing?**\nWe know that some type requires some fiels, and some fields aren't optional, when we got that situation, why we unwrapp optionals all the time?\nWe spent a lot of time taking care about this errors, processing them, logging some info...\nWe don't need optional types when types aren't optional, we need not optional types, then we throw very **useful** errors.\n\nWhen we parse JSON objects and the parsing process fails, we want get info about the error, something like `required field \"name\" not found`, or `trying cast String to Int`, whatever... But we not only want this, when we are making complex request  with nested objects, we also want know what object has failed. JASON provide all that data for us.\nWhen something fail, the error will print `required field \"name\" not found at Person.self` for example.\n\n## Extending framework types.\n\nYes, you can directly parse Foundation or whatever framework type. URL for example. We want cast strings into URL directly then...\n\n```swift\n\n///Create an extension of type implementing ConvertibleFromJSON\nextension URL: ConvertibleFromJSON {\n\n    /// We only need the method from(_, at:), with this, we create the URL\n    /// casting the given data, and taking care about possible casting errors.\n    ///\n    /// at: String its provided to us to bring the possiblity of give information about the parsing object.\n    public static func from(_ object: Any, at: String) throws -\u003e URL {\n        guard let string = object as? String else {\n            throw JASONError.TryingCast(object: object, to: \"String\", at: at)\n        }\n        guard let url = URL(string: string) else {\n            throw JASONError.TryingCast(object: object, to: \"URL\", at: at)\n        }\n\n        return url\n    }\n\n}\n\n```\n\n\n## Your custom types\n\nAnd when we have nested objects, our objest only need implement `ExpressibleByJSON`, like `Person` declared above.\nThen we can parse `Persons` like parse `String`\n```\nlet person: Person = try json \u003c\u003c\u003c \"person\"\n```\n\nAnd not only that!\nJASON also will parse for you arrays of persons if you want. when you have a JSON like this...\n\n```json\n\n{\n    \"employees\": [{\n                  \"name\": \"Ram\",\n                  \"email\": \"ram@gmail.com\",\n                  \"age\": 23\n                  }, {\n                  \"name\": \"Shyam\",\n                  \"email\": \"shyam23@gmail.com\",\n                  \"age\": 28\n                  }, {\n                  \"name\": \"John\",\n                  \"email\": \"john@gmail.com\",\n                  \"age\": 33\n                  }, {\n                  \"name\": \"Bob\",\n                  \"email\": \"bob32@gmail.com\",\n                  \"age\": 41\n                  }]\n}\n```\n\nWe only do this:\n```swift\nlet employees: [Employee] = try json \u003c\u003c\u003c \"employees\"\n```\nAnd all work done.\n\n## No key needed\n\nIf your json data comes without key, you can parse it too.\n\n```json\n\n[{\n\"name\": \"Ram\",\n\"email\": \"ram@gmail.com\",\n\"age\": 23\n}, {\n\"name\": \"Shyam\",\n\"email\": \"shyam23@gmail.com\",\n\"age\": 28\n}, {\n\"name\": \"John\",\n\"email\": \"john@gmail.com\",\n\"age\": 33\n}, {\n\"name\": \"Bob\",\n\"email\": \"bob32@gmail.com\",\n\"age\": 41\n}]\n\n```\n\n```swift\n\nlet employees = try json\u003c\u003c\u003c as [Employee]\n\n```\n\n## Installation\n\nJASOON is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"JASOON\"\n```\n\n## Author\n\nJulián Alonso, julian.alonso.dev@gmail.com\n\n## License\n\nJASON is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulianalonso%2Fjasoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulianalonso%2Fjasoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulianalonso%2Fjasoon/lists"}