I have a JSON dictionary that looks like this:
{
"111": {"dates" : [<array_of_dates>],
"members" : [<array_of_members>]},
"112": {"dates" : [<array_of_dates>],
"members" : [<array_of_members>]},
"113": {"dates" : [<array_of_dates>],
"members" : [<array_of_members>]}
}
As you can see, the key for the nested dictionary is variable (111, 112, 113).
So far, every Mantle model I have made has fixed keys so I don't know how to handle this particular situation.
Any ideas?
you have several options:
{"property": { "111": …, "222": … }}
) so you can actually bind to itOnce you have a value you can pass use in +JSONKeyPathsByPropertyKey
, you can write a custom value transformer to process the model.
Here are two examples to get you started:
mtl_arrayMappingTransformerWithTransformer
https://github.com/Mantle/Mantle/blob/master/Mantle/NSValueTransformer%2BMTLPredefinedTransformerAdditions.m#L106-L229The most important part is to figure out how do you want to use the map you're getting from JSON. Maybe you're better off by keeping it as a dictionary in a private property and write public methods accessing it in a way that makes sense