Skip to content

Podul/AnyJSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnyJSON

  1. 使用
let json1 = """
{
  "sites": {
    "id": "1",
    "name": "菜鸟教程",
    "url": "www.runoob.com",
    "lang": {"en": "false", "zn": "true"},
    "address": [
      {"city": "beijing", "province": "null"},
      {"city": "chengdu", "province": "sichuan"}
    ]
  }
}
"""

let data = json1.data(using: .utf8)
let value = try JSONDecoder().decode(AnyJSON.self, from: data!)

print(value.sites.id.intValue)
output: 1

print(value.sites.name.stringValue)
output: 菜鸟教程

About

Swift JSON 解析

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages