https://github.com/0xlet/dataobject
📦 DataObject(Any)
https://github.com/0xlet/dataobject
any dataobject json object surl swift wtv
Last synced: about 2 months ago
JSON representation
📦 DataObject(Any)
- Host: GitHub
- URL: https://github.com/0xlet/dataobject
- Owner: 0xLet
- License: mit
- Created: 2021-03-14T19:23:56.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-12T01:51:26.000Z (about 4 years ago)
- Last Synced: 2025-03-15T05:20:14.272Z (2 months ago)
- Topics: any, dataobject, json, object, surl, swift, wtv
- Language: Swift
- Homepage:
- Size: 20.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DataObject
*DataObject(Any)*
## Basic Example
```swift
let obj = DataObject("init_value")
.set(variable: "SomeValue", value: "qwerty")
.set(variable: "nil", value: nil)XCTAssertEqual(obj.value(), "init_value")
XCTAssertEqual(obj.SomeValue.value(), "qwerty")
XCTAssertEqual(obj.nil, DataObject())
```## [SURL](https://github.com/0xLeif/SURL) JSON Example
```swift
"https://jsonplaceholder.typicode.com/users/7".url?
.get { (obj) in
print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
print(obj.data)
}
```
JSON```json
{
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "[email protected]",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo": {
"lat": "24.8918",
"lng": "21.8984"
}
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
}
```
### Output: obj.data
```swift
DataObject {
| Variables
| * id: 7 (__NSCFNumber)
| * value: 500 bytes (Data)
| * address: {
city = Howemouth;
geo = {
lat = "24.8918";
lng = "21.8984";
};
street = "Rex Trail";
suite = "Suite 280";
zipcode = "58804-1099";
} (__NSDictionaryI)
| * email: [email protected] (__NSCFString)
| * json: {
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "[email protected]",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo": {
"lat": "24.8918",
"lng": "21.8984"
}
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
} (String)
| * website: elvis.io (NSTaggedPointerString)
| * username: Elwyn.Skiles (__NSCFString)
| * company: {
bs = "generate enterprise e-tailers";
catchPhrase = "Configurable multimedia task-force";
name = "Johns Group";
} (__NSDictionaryI)
| * phone: 210.067.6132 (__NSCFString)
| * name: Kurtis Weissnat (__NSCFString)
}
```## [WTV](https://github.com/0xLeif/WTV) Example
```swift
"https://jsonplaceholder.typicode.com/users/7".url?
.get { (obj) in
print(obj.data.wtv(named: "name")!)
}
```### Output: obj.data.wtv(named: "name")
```swift
DataObject.variables["company"]["name"] 👉 FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] 👉 FOUND: (label: Optional("name"), value: Kurtis Weissnat)
```