mercredi 4 juillet 2018

Iterate over Maps with Java reflections

I need to write a programm which converts any Object in Java into JSON with reflections. I am not allowed to use any library like gson.

Now I am at the point where I need to convert Maps into JSON Strings. With arrays everything worked fine, I can just iterate over the array.

But with maps I dont get how to iterate over its objects. I detect if the object is a Map with:

if (o.getClass().getSuperclass().getName().equals("java.util.AbstractMap"))

But now I dont get how to itereate over the objects inside the Map.





Aucun commentaire:

Enregistrer un commentaire