Nothing Special   »   [go: up one dir, main page]

Skip to content

Releases: 0xLet/DataObject

1.1.1

12 May 01:51
9b3d4ac
Compare
Choose a tag to compare

DataObject

DataObject(Any)

Basic Example

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 JSON Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
        print(obj.data)
}
JSON
{
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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

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: Telly.Hoeger@billy.biz (__NSCFString)
|    * json: {
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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 Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.data.wtv(named: "name")!)
}

Output: obj.data.wtv(named: "name")

DataObject.variables["company"]["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Kurtis Weissnat)

1.1.0

10 May 16:13
28c95df
Compare
Choose a tag to compare

DataObject

DataObject(Any)

Basic Example

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 JSON Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
        print(obj.data)
}
JSON
{
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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

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: Telly.Hoeger@billy.biz (__NSCFString)
|    * json: {
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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 Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.data.wtv(named: "name")!)
}

Output: obj.data.wtv(named: "name")

DataObject.variables["company"]["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Kurtis Weissnat)

1.0.0

28 Apr 21:57
9566454
Compare
Choose a tag to compare

DataObject

DataObject(Any)

Basic Example

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 JSON Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
        print(obj.data)
}
JSON
{
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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

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: Telly.Hoeger@billy.biz (__NSCFString)
|    * json: {
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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 Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.data.wtv(named: "name")!)
}

Output: obj.data.wtv(named: "name")

DataObject.variables["company"]["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Kurtis Weissnat)

0.2.2

14 Apr 17:24
Compare
Choose a tag to compare
Updated dependencies

Always add Data when possible

16 Mar 02:34
Compare
Choose a tag to compare
0.2.1

Always add Data

Fuable

16 Mar 02:07
Compare
Choose a tag to compare

DataObject: FuableClass

DataObject(Any)+SwiftFu

Basic Example

let obj = DataObject("init_value")
    .add(variable: "SomeValue", value: "qwerty")
    .add(variable: "nil", value: nil)

XCTAssertEqual(obj.value(), "init_value")
XCTAssertEqual(obj.SomeValue.value(), "qwerty")
XCTAssertEqual(obj.nil, DataObject())

SURL JSON Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
        print(obj.data)
}
JSON
{
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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

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: Telly.Hoeger@billy.biz (__NSCFString)
|    * json: {
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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 Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.data.wtv(named: "name")!)
}

Output: obj.data.wtv(named: "name")

DataObject.variables["company"]["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Kurtis Weissnat)

DataObject(Any)

14 Mar 19:27
ad64de5
Compare
Choose a tag to compare

DataObject

DataObject(Any)

Basic Example

let obj = DataObject("init_value")
    .add(variable: "SomeValue", value: "qwerty")
    .add(variable: "nil", value: nil)

XCTAssertEqual(obj.value(), "init_value")
XCTAssertEqual(obj.SomeValue.value(), "qwerty")
XCTAssertEqual(obj.nil, DataObject())

SURL JSON Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.variables.keys) // [AnyHashable("response"), AnyHashable("data")]
        print(obj.data)
}
JSON
{
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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

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: Telly.Hoeger@billy.biz (__NSCFString)
|    * json: {
  "id": 7,
  "name": "Kurtis Weissnat",
  "username": "Elwyn.Skiles",
  "email": "Telly.Hoeger@billy.biz",
  "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 Example

"https://jsonplaceholder.typicode.com/users/7".url?
    .get { (obj) in
        print(obj.data.wtv(named: "name")!)
}

Output: obj.data.wtv(named: "name")

DataObject.variables["company"]["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Johns Group)
DataObject.variables["name"] πŸ‘‰ FOUND: (label: Optional("name"), value: Kurtis Weissnat)