Using Map in Java (or other strongly-typed languages) to work with unstructured data
https://softwareengineering.stackexchange.com/questions/136123
-
04-11-2019 - |
Question
After looking at the core data type for frameworks that deal with unstructured data in java:
- json java library: JsonObject
- Mongodb java api: BasicBSONObject
- SolrJ (Solr java client): SolrDocument
the common theme seems to be that data are first de-serialized into Map, then transformed into an given class by reflection.
So this raises the question, why not just work with these Map (or sub-type of map) directly? You can extend Map and create your own sub-type, and you will still have all the benefit of OO programming.
Edit
I am not concerned with the cost of deserialization, but the flexibility that Map offers when dealing with unstructured data. By this, I mean not having to define a class that the data can be deserialized into.
Edit 2
I am more interested in the "why not (disadvantages)", since the framework I mentioned already demonstrated that it could be done.
No correct solution