DictionaryUtils 0.5.3

DictionaryUtils 0.5.3

测试已测试
语言语言 SwiftSwift
许可 MIT
发布上次发布2019年6月
SPM支持 SPM

Will Powell 维护。



alt text

DictionaryUtils

Dictionary utils 允许您使用类似 JSON 的引用来遍历对象。

CI Status Version License Platform

示例

要运行示例项目,首先克隆仓库,然后从示例目录中运行 pod install

安装

DictionaryUtils 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:

pod "DictionaryUtils"

用法

假设我们定义了一个包含数组的任意字典。我们理想地希望能够以更友好的方式访问属性,而不必引用每个子对象。

let data = ["data":["ary":[["value":1,"property1":"WELCOME"],["value":0,"property1":"WELCOME2"]]]]

我们可以使用以下代码找到子属性

do {
    let output = try data.readString("data.ary[0].property1")
    print(output!)
}catch{
    print("ERROR")
}

这个库还允许您在数组中进行基于参数的发现,如下例所示

do {
    let output = try data.readString("data.ary[value=0].property1")
    print(output!)
}catch{
    print("ERROR")
}

作者

willpowell8

许可协议

DictionaryUtils 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。