2 ms·
> doing JSON in Java is an ugly, ugly thing Why do you think so? Jackson and Gson work very well. Serialising and deserialising from/to POJO/JSON is trivial wi
by Traubenfuchs 8y ago
> doing JSON in Java is an ugly, ugly thing
Why do you think so? Jackson and Gson work very well. Serialising and deserialising from/to POJO/JSON is trivial with them.
- sonnyblarney 8y agoJSON and Javascript data objects are essentially directly interchangeable. In Java, you have to abstract the document and write a lot of code to access, add, remove things etc. - or - because there is no such thing as an untyped POJO in java, you have to set up a ton of things if you want to use real objects.
- Traubenfuchs 8y agoInstead of using a typed POJO you can deserialize/serialize a Map<String, Object>. You could also use a POJO for the fields you know and put a map inside for the fields you don't know. If that's not enough you can use JsonNode, or ObjectNode where you can freely add and remove json values.
- sonnyblarney 8y agoOk, touché, good point.