Skip to content

swiftdo/json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

swiftdo/json

swift json 解析库

  • 完成 json 打印
  • 完成 json 解析

实现文章

使用

let str = "{  \"a\":[8,9,10],\"c\":{\"temp\":true,\"say\":\"hello\",\"name\":\"world\"},   \"b\":10.2}"

print("json 字符串::\n\(str) \n")

do {
    // 解析 json 字符串
    let result = try parseJson(str: str)
    print("\n返回结果::")
    // 格式化 json 字符串
    print(prettyJson(json: result))
} catch  {
    print(error)
}

结果输出:

json 字符串::
{  "a":[8,9,10],"c":{"temp":true,"say":"hello","name":"world"},   "b":10.2} 


返回结果::
{
    "a":[
        8,
        9,
        10
    ],
    "c":{
        "temp":true,
        "say":"hello",
        "name":"world"
    },
    "b":10.2
}

参考:

About

码了个 swift json 解析器

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages