4 ms·
Java is fine at decoding Json if you know what the fields are going to be. It's not like creating an object with the fields you want is very difficult and then
by tdb7893 10y ago
Java is fine at decoding Json if you know what the fields are going to be. It's not like creating an object with the fields you want is very difficult and then libraries will deserialize it easily. It's also not hard to create a tool that will generate a POJO class from a string of Json. It doesn't really take time so the only problem is that it is yet another class on the classpath
- jomamaxx 10y ago"Java is fine at decoding Json " It does the job but it's not nearly as nice as javascript or python. It's about double the code in Java and it doesn't read nicely. I think it depends on what you're doing.
- tdb7893 10y agoJava definitely makes it harder to work with json but the only problem I run in to is that I need classes (which I just autogenerate) for every json object. Serializing and deserializing json is a one liner once you have classes set up for them to deserialize into. Again, it is definitely harder than in Python and Javascript but I work with Java and json every day and it's generally only a huge difficulty if you need a strange edge case. EDIT: also, java is bad at dealing with json if the api could return data in multiple different schemas and you don't know which one it is until you parse it but I've only run into this once and it's just bad API design.
- jomamaxx 10y agoAh, yeah, if you have known-entities ahead of time it's no problem via serialization. Developing/experimenting/scripting is where it's painful.