init()
Creates a new, reusable JSON decoder with the default formatting settings and decoding strategies.
新しい、再利用可能なJSONデコーダを省略時の書式設定の設定とデコーディング戦略で作成します。
Availability 有効性
Technology
class JSONDecoder
The example below shows how to decode an instance of a simple Grocery
type from a JSON object. The type adopts Codable
so that it’s decodable using a JSONDecoder
instance.
下の例は、単純なGrocery
型のインスタンスを JSONオブジェクトからデコードする方法を示します。この型はCodable
を採用します、それでそれはJSONDecoder
インスタンスを使ってデコード可能です。
struct GroceryProduct: Codable {
var name: String
var points: Int
var description: String?
}
let json = """
{
"name": "Durian",
"points": 600,
"description": "A fruit with a distinctive scent."
}
""".data(using: .utf8)!
let decoder = JSONDecoder()
let product = try decoder.decode(GroceryProduct.self, from: json)
print(product.name) // Prints "Durian"
init()
func decode<T>(T.Type, from: Data) -> T
var keyDecodingStrategy : JSONDecoder.KeyDecodingStrategy
enum JSONDecoder.KeyDecodingStrategy
var userInfo : [CodingUserInfoKey : Any]
var allowsJSON5 : Bool
var assumesTopLevelDictionary : Bool
var dateDecodingStrategy : JSONDecoder.DateDecodingStrategy
enum JSONDecoder.DateDecodingStrategy
var dataDecodingStrategy : JSONDecoder.DataDecodingStrategy
enum JSONDecoder.DataDecodingStrategy
var nonConformingFloatDecodingStrategy : JSONDecoder.NonConformingFloatDecodingStrategy
enum JSONDecoder.NonConformingFloatDecodingStrategy
typealias JSONDecoder.Input
class JSONEncoder
class JSONSerialization