This package provides a simple container for any JSON-data, that conforms to the Codable
protocol.
Use this when you want to send the result of a function returning JSON-data as a Decodable
, to another function accepting JSON-data as an Encodable
; e.g. if you want to send the result of Marionette
's evaluate
to a JSBridge function.
dependencies: [
.package(url: "https://github.com/LinusU/GenericJSONType", from: "1.0.0"),
]
github "LinusU/GenericJSONType" ~> 1.0.0
import GenericJSONType
let myJSONString = " ~~ any valid JSON string here ~~ ".data(using: .utf8)!
let decoder = JSONDecoder()
let decoded = try decoder.decode(JSON.self, from: myJSONString)
// `decoded` is now a structure representing the JSON data
let encoder = JSONEncoder()
let encoded = try encoder.encode(decoded)
// `encoded` is now a JSON representation of the data we started out with
The Xcode project is generated automatically from project.yml
using XcodeGen. It's only checked in because Carthage needs it, do not edit it manually.
$ mint run yonaskolb/xcodegen
💾 Saved project to GenericJSONType.xcodeproj