I thought this question would work for my situation, but my lack of experience with Mantle and iOS in general did not end my train of thought. Basically, I have a big chunk of JSON with nested dictionaries and arrays that I want to convert to Mantle objects.
"features": {
"App": {
"status": "_ACTIVE",
"unavailableReasons": [],
"modernCapabilities": [{
"capabilityType": "LOCK_AUTO_REPLY",
"providerStatuses": [{
"providerType": "MY_PROVIDER",
"status": false,
"unavailableReasons": ["NOT_SUPPORTED_BY_PRODUCT", "DEVICE_OS_NOT_SUPPORTED"]
}]
},
...
...
{
"capabilityType": "LOCK_CONTACT_WHITELIST",
"providerStatuses": [{
"providerType": "OTHER_PROVIDER",
"status": true,
"unavailableReasons": []
}]
}
]}
}
, , "" /. , "App" ( "modernCapabilities" ..). , , , "App" .
:
+ (NSValueTransformer *)featureTypesJSONTransformer {
NSValueTransformer *transformer = [NSValueTransformer valueTransformerForName:@"FeatureStatus"];
return [MTLValueTransformer transformerWithBlock:^NSDictionary *(NSDictionary *features) {
NSMutableDictionary *transformedValues = [[NSMutableDictionary alloc] init];
for (NSString *key in features) {
id transformedValue = [transformer transformedValue:[features objectForKey:key]];
if (transformedValue ) {
[transformedValues setObject:transformedValue forKey:key];
}
}
return transformedValues;
}];
}
, , , FeatureStatus (@{ "App" :})
, [FeatureStatus transformValue:], JSONKeyPathsForPropetyKey, "status", "unavailableReasons" "modernCapabilities".
? ValueTransform, , ?