I'm currently trying to simplify my Obj-C Model but it seems the json data makes it a bit more complex than I thought. I can't get the array data to convert to some booleans.
As far as I know it's impossible to use the Frameworks JSONKeyPathsByPropertyKey to define that the key is something like this: @"gsRightIPServerStart", @"rights.name['RIGHT_IP_SERVERSTART'].granted" or at least the posebility to access the serializing dicitonary within the used class eg. my FNPServer class.
This is a part of the JSON response I have to use:
...,
isowner": false,
"rights":
[
{
"name": "RIGHT_IP_SERVERSTART",
"granted": true
},
{
"name": "RIGHT_IP_SERVERREMOVE",
"granted": true
},
{
"name": "RIGHT_IP_SWITCHCONFIGMODE",
"granted": true
},
{
"name": "RIGHT_IP_SERVERCREATE",
"granted": true
}
]}
It's an simple Array that could be easily represented as Boolean. In this case some NSNumbers (CoreData):
@interface FNPServer : MTLModel <MTLJSONSerializing>
...
@property (nonatomic, strong) NSNumber * gsRightIPServerStart;
@property (nonatomic, strong) NSNumber * gsRightIPServerStop;
@property (nonatomic, strong) NSNumber * gsRightIPServerRestart;
@property (nonatomic, strong) NSNumber * gsRightIPServerModify;
@end
I can't find a solution to get the source dict while or after generating this Object to handle the conversion by myself.
I don't want to make serveral different classes and check the property to generate an array full of full fledged Objects for a simple yes or no question. It should work without "help from outside" otherwise i have to check a bunch of requests if the data is present or not.
Thanks