android - Realm: Field Map inside another Map as RealmObject -
i need parse json incoming external system. here json example:
{ "address": "my address", "contacts": "my contacts", "exchangeratesmap": { "chf": { "field1": "7.103", "field2": "11.003" }, "eur": { "field1": "90.123", "field2": "1.003" }, "usd": { "field1": "0.103", "field2": "20.123" } }, "name": "name of organization", "id": 1 }
as result create java pojo (not realm) in android application:
public class exchangerate { private int id; private string name; private string address; private string contacts; private map<string, map<string, string>> exchangeratesmap = new hashmap<string, map<string, string>>(); }
and work fine. ok.
and need migrate java pojo realm object.
question: how object exchangerates realmobject?
realm doesn't support maps yet (see https://github.com/realm/realm-java/issues/759), can convert list hand doing this:
public class exchangerateitem extends realmobject { public string key; public double field1; public double field2;
}
public class exchangerate { private int id; private string name; private string address; private string contacts; private realmlist<exchangerateitem> exchangerates; }
you need find way convert exchangerate blocks 1 object though. how depend on kind of json deserializer use or if use json directly.
Comments
Post a Comment