https://github.com/elegantchaos/jsonrepresentable
Swift to JSON conversion utilities
https://github.com/elegantchaos/jsonrepresentable
json swift
Last synced: 11 months ago
JSON representation
Swift to JSON conversion utilities
- Host: GitHub
- URL: https://github.com/elegantchaos/jsonrepresentable
- Owner: elegantchaos
- License: mit
- Created: 2022-01-12T16:33:48.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-15T09:08:47.000Z (almost 4 years ago)
- Last Synced: 2025-02-04T20:18:17.238Z (over 1 year ago)
- Topics: json, swift
- Language: Swift
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JSONRepresentable
This package defines two protocols: `JSONType` and `JSONRepresentable`.
## JSONType
Types which conform to `JSONType` can be directly represented in JSON.
The package adds conformance to Swift's basic types: `Bool`, `Int`, `Double`, `String`.
It defines a dictionary type `JSONDictionary`, with `String` keys and `JSONType` values.
It also defines an array type `JSONArray`, with `JSONType` values.
## JSONRepresentable
Types which conform to `JSONRepresentable` can be converted into a `JSONType`, using the `asJSONType` method.
The package adds conformance to `JSONRepresentable` to various standard types:
- `Array` (where Element is `JSONRepresentable`)
- `CFString`
- `Date`
- `NSArray`
- `NSDate`
- `NSDictionary`
- `NSNumber`
- `NSNull`
- `NSString`