3 ms·
JSON 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, r
by sonnyblarney 8y ago
JSON 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.