https://github.com/cemolcay/dictutils
Adds bunch of extensions and operators that would make working with Dicitonaries easier.
https://github.com/cemolcay/dictutils
dictionary extension json merge swift
Last synced: 3 months ago
JSON representation
Adds bunch of extensions and operators that would make working with Dicitonaries easier.
- Host: GitHub
- URL: https://github.com/cemolcay/dictutils
- Owner: cemolcay
- License: mit
- Created: 2019-02-08T21:35:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-28T07:53:06.000Z (over 6 years ago)
- Last Synced: 2025-04-06T10:53:23.353Z (about 1 year ago)
- Topics: dictionary, extension, json, merge, swift
- Language: Swift
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DictUtils
====
Adds bunch of extensions and operators that would make work with Dictionaries easier. If you are working with JSON and don't want to use dependencies like SwiftyJSON and keep everything native, you can peacefully grab that little helper.
Requirements
----
* Xcode 10+
* Swift 4.0+
* iOS 8.0+
* tvOS 9.0+
* macOS 10.10+
* watchOS 2.0+
Install
----
#### Manually
* Copy the `DictUtils.swift` file into your codebase.
#### Cocoapods
```
pod 'DictUtils'
```
Extensions
-----
* `+` and `+=` operators
* Merges two dictionaries without hassle.
* Typed, chainable subscripts
* Get `int`, `string`, `bool`, `double`, `[String: Any]` and their array types.
``` swift
let index = dataSource[int: "index"]
let name = dataSource[string: "name"]
let zipCode = dataSource[dict: "users"]?[0][dict: "address"]?[string: "zip"]
```
* Initialize a dictionary from a JSON string.
```
let dict = [String: Any](json: response.string)
```
* Get pretty printed string with `dataSource.prettify()`.