realm不支持hashmap这种形式
stackoverflow给出了解决方案
http://stackoverflow.com/ques...
class MyData extends RealmObject {
private RealmList<MyMap> myMap;
}
class MyMap extends RealmObject {
private String key;
private MyClass value;
}
但是我用gson解析时会报错
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2656 path $.layers[0].icons
因为map是一个对象,而private RealmList<MyMap> myMap;是一个数组
应该怎样解析呢?
如果把Map 轉換成RealmList#🎜#如果把Map 轉換成RealmList
也需要回傳的json格式做變更, 需要把{myMap: {key1: value1, key2: value2}}的格式修改成
{myMap: [
]
}