JSON과 동등한 Foundation 객체 간에 변환되는 객체
class JSONSerialization: NSObject
JSONSerialization
클래스를 사용하여 JSON을 Foundation 객체로 변환
하고 Foundation 객체를 JSON으로 변환
할 수 있습니다.
JSON으로 변환할 수 있는 Foundation 객체에는 다음 속성이 있어야 합니다.
다른 규칙이 적용될 수 있습니다. isValidJSONObject(_:)
를 호출하거나 변환을 시도하는 것이 지정된 객체를 JSON 데이터로 변환할 수 있는지 여부를 확인하는 결정적인 방법입니다.
Thread Safety
On iOS 7 and later and macOS 10.9 and later JSONSerialization is thread safe.
class func jsonObject(with: Data, options: JSONSerialization.ReadingOptions) -> Any
class func jsonObject(with: InputStream, options: JSONSerialization.ReadingOptions) -> Any
class func data(withJSONObject: Any, options: JSONSerialization.WritingOptions) -> Data
Foundation 객체에서 JSON 데이터를 반환합니다.
class func writeJSONObject(Any, to: OutputStream, options: JSONSerialization.WritingOptions, error: NSErrorPointer) -> Int
지정된 JSON 객체를 스트림에 씁니다.
class func isValidJSONObject(Any) -> Bool
지정된 객체를 JSON 데이터로 변환할 수 있는지 여부를 나타내는 부울 값을 반환합니다.
struct JSONSerialization.ReadingOptions
JSON 데이터에서 Foundation 개체를 생성할 때 사용되는 옵션—jsonObject(옵션: 포함) 및 jsonObject(옵션: 포함)를 참조
struct JSONSerialization.WritingOptions
데이터 쓰기 옵션.
{ } Using JSON with Custom Types
class JSONEncoder
class JSONDecoder