I have a class that store a Long value and JSONArray.
Class SomeClass {
private Long longValue;
private JSONArray jsonArray;
//Default and parameterised constructors.
//Getters and Setters.
}
I'm storing these values in a NavigableMap<?, SomeClass>. ? - String / Long. I get a treeMap from MapDB as follows:
private DB mapDB = MapDBUtil.getMapDB(); //Opening or creating and getting MapDB DB object
NavigableMap<Long,SomeClass> treeMap = mapDB.treeMap(treeName).keySerializer(Serializer.LONG).valueSerializer(Serializer.ELSA).createOrOpen();
When I try to add some value to the map obtained, say:
SomeClass instance = new SomeClass("Hello", jsonArray);
treeMap.put("test", instance);
I get org.mapdb.DBException$SerializationError. I figured the issue is due to serializing JSONArray. I want to either implement a custom serializer or use some other way to serialize and store this data. I tried implementing Serializable and also ElsaSerializer in 'SomeClass' but both of those don't seem to work. I have also tried to use Serializer.JAVA when Serializable interface is implemented but that doesn't work too. I'm not sure about what I'm doing wrong. Any help would be really appreciated.