From 443fbedbbeed0c2fe91d81a6b9630ab525fad92b Mon Sep 17 00:00:00 2001 From: Jungpyo Hong <54448459+jphong1111@users.noreply.github.com> Date: Fri, 30 Apr 2021 21:20:43 -0500 Subject: [PATCH] edit json decoder --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7148701..7579dd7 100644 --- a/README.md +++ b/README.md @@ -160,8 +160,7 @@ Then use it ## API -### Various API Site -- [rapidAPI](https://www.rapidapi.com) +API(Application Programming Interface) is an interface that defines interactions between multiple software applications or mixed hardware-software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc. ## JSON JSON is a language-independent data format @@ -186,8 +185,27 @@ This extension makes JSON more structable ### JSON Decoding +To use JSON Decoding in swift, you have to define the model to be Codable or Decodable + +```swift +public typealias Codable = Decodable & Encodable +``` + +> Decodable can only decode the json data. Can't encoded json file!! + +```swift +struct User: Codable { + var first_name: String + var last_name: String + var country: String +} +``` + ### JSONSerialization +### Various API Site +- [rapidAPI](https://www.rapidapi.com) + ## GCD GCD(Grand Central Dispatch) is a low-level API for managing concurrent operations. It can help you improve your app’s responsiveness by deferring computationally expensive tasks to the background.