3 ms·
I find Java pretty nice for handling JSON serialization/deserialization these days. Just define some records for the expected structure, and Jackson's object m
by sixbrx 4y ago
I find Java pretty nice for handling JSON serialization/deserialization these days. Just define some records for the expected structure, and Jackson's object mapper handles the rest.
- eropple 4y agoIt's the "defining some records" part that's slow and gritty. JSON is usually an interchange format, and Java class construction is either slow, tedious, and manual, or involves massaging a code generator (which, at least the last time I checked a few months ago, weren't very good in Java).
- vips7L 4y agoI don’t see how declaring a data model class is anymore difficult in Java than another typed language. record Thing(String name, int size, LocalDate when) {} The only way I could see this being easier is to forgo type safety completely.
- eropple 4y agoYou're assuming you only have to define it in one language. JSON is an interchange format. The canonical way to express it is JSON Schema, and the tools are unpleasant in Java. So is dealing with structural typing of polymorphic responses. In an ideal world we wouldn't have those, but we live in this one. These things are just better when you aren't in a nominatively typed language with some pretty crusty assumptions.