custom_attributes
, value
- массивы
Alamofire.request("http://adorableprojects.store/rest/V1/detailProduct/configurable-product").responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!).dictionaryValue
if let resData = swiftyJsonVar["custom_attributes"]?.arrayValue , let sec = resData.first?.dictionaryValue["value"]?.arrayValue , let color = sec.first?.dictionaryValue["color"]?.arrayValue {
print("dhjjhdhdsjhdsjdshjdsjhds ",color)
}
else {
}
}
}
Редактировать : доступ к размеру
Alamofire.request("http://adorableprojects.store/rest/V1/detailProduct/configurable-product").responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!).dictionaryValue
if let resData = swiftyJsonVar["custom_attributes"]?.arrayValue , let sec = resData.first?.dictionaryValue["value"]?.arrayValue , let color = sec[1].dictionaryValue["size"]?.arrayValue {
print("dhjjhdhdsjhdsjdshjdsjhds ",size)
}
else {
}
}
}
кстати рекомендую
struct Root: Codable {
let customAttributes: [CustomAttribute]
enum CodingKeys: String, CodingKey {
case customAttributes = "custom_attributes"
}
}
struct CustomAttribute: Codable {
let attributeCode: String
let value: [Value]
enum CodingKeys: String, CodingKey {
case attributeCode = "attribute_code"
case value
}
}
struct Value: Codable {
let color: [Color]
}
struct Color: Codable {
let valueIndex, label, productSuperAttributeID, defaultLabel: String
let storeLabel: String
let useDefaultValue: Bool
enum CodingKeys: String, CodingKey {
case valueIndex = "value_index"
case label
case productSuperAttributeID = "product_super_attribute_id"
case defaultLabel = "default_label"
case storeLabel = "store_label"
case useDefaultValue = "use_default_value"
}
}