Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
iWECon committed Jul 16, 2024
1 parent f67831b commit adde03b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,31 @@ try await req.client.post(uri, headers: headers) { inoutReq in
}
```

*setNull & Compact Map Values*
```swift
let json = """
{
"name": "Lookup",
"age": 3,
"versions": [
"2.4.0", "2.0.0", "1.0.0"
],
"birth": "202"
}
let lookup = Lookup(json)
print(lookup.versions.0.string) // -> "2.4.0"
lookup["versions.0"] = "2.4.1"
print(lookup.versions.0.string) // -> "2.4.1"
// setNull
let newLookup = lookup.setNull(keys: ["birth"])
newLookup.hasKey("birth") // -> true, but value is null(nil)
let compactLookup = newLookup.compactMapValues()
newLookup.hasKey("birth") // -> false, no key no value
"""
```

More usage references `LookupTests.swift`: [LookupTests.swift](https://github.com/iWECon/Lookup/blob/main/Tests/LookupTests/LookupTests.swift)


Expand Down
6 changes: 3 additions & 3 deletions Tests/LookupTests/LookupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ final class LookupTests: XCTestCase {
XCTAssertEqual(rejectLookup.age.int, 18)

var aLookup = Lookup(
["name": "wei", "childs":[
["name": "iwecon", "childs":[
[
"name": "kai", "id": nil, "age": 18,
"name": "lookup", "id": nil, "age": 18,
"childs": [
["name": "lan", "age": 12, "id": nil]
["name": "Lookup.dynamicMember", "age": 12, "id": nil]
]
]
]]
Expand Down

0 comments on commit adde03b

Please sign in to comment.