RealmSwift-JSON
RealmSwift-JSON copied to clipboard
how to parse dictionary within dictionary
Hi,
How can we parse dictionary within dictionary? Suppose you have key1 : val1, key2 : { test1 : valtest1 test2 : valtest2 }
from Matthew's Realm-JSON, I can do like
- (NSDictionary *)JSONInboundMappingDictionary { return @{ @"key1": @"key1", @"key2.test1": @"test1", @"key2.test2": @"test2" }
Do we have something similar with yours? Thanks!
Hello ordinaryman09 Thank you for suggesting the issue.
Unfortunately, RealmSwift-JSON doesn't support the way that you mentioned like key2.test.
But if you make models which inherit Object, you could use like the way that you want.
Here is the example of your case.
class Model1:Object {
dynamic var key1:String?
dynamic var key2:Model2?
}
class Model2:Object {
dynamic var test1:String?
dynamic var test2:String?
}
and then you don't need to implement JSONInboundMappingDictionary it would be implemented automatically.
I wish it would help you.