I need to store some data coming from a API call as JSON locally using CoreData.
The problem is, the JSON is too complicated to me to handle in CoreData. I’m getting JSON as a Dictionary
with 4 keys, and these 4 keys again holds Dictionary
's and those Dictionary
's have Array
's and Dictionary
's.
Now, I don’t really know how I should design Entities and Attributes for this requirement, but I tried to do that and what I did is, I created a Entity (say XYZ) and this entity has 4 relations (one to one) to 4 other entities and these four entities are nothing but four Dictionary
's which I have got in the JSON file. And I’m storing these Array
's and Dictionary
's as transformable types. It gets a little confusing, right? So let me put the JSON data here
{
outerKey1 = {
someKey = “Some String";
disableAutoFill = 1;
disableABC = 1;
disableXYZ = 1;
disableThis = 1;
disableThat = 1;
disableBla = 1;
disableBlaBla= 1;
disableBlaBlaBlaBla = 1;
disableBlaBlaBlaBlaBlaBla= 1;
};
outerKey2 = {
someKey = (
{
markPath = 0;
title = "Some Name";
url = "http://www.BlaBla.com";
},
{
markPath = 0;
title = "Some Name";
url = "http://www.something.com";
},
{
markPath = 0;
title = Yahoo;
url = "http://www.yahoo.com";
},
{
Path = 0;
title = “title";
url = "http://www.title.com";
}
);
enabled = 1;
};
outerKey3 = {
enabled = 1;
gatewayIP = "192.172.169.10";
gatewayPort = 8080;
gatewayRoutingUrls = (
"www.kuchbhi.com",
"www.oh-teri.com"
);
};
outerKey4 = {
SomeCategories = (
SomeCategories,
someOtherCategories
);
defaultUrl = "www.meriapniwebsite.com";
enabled = 1;
exceptionUrls = (
"www.kuchbhihojay.com"
);
filterUrls = (
"www.kuchtobhi.com",
"www.kyaaapjhandhai.com"
);
filteringFlag = 1;
};
}
Is my approach ok or does it need to be corrected? Or do I need to implement it in an entirely different fashion. Please help me, thanks