- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is also a good way to copy JSON files.
Admin
This is the sort of situation where it's time to do a full rewrite either of the code or your CV.
Admin
Those who think there is a relationship between Java and JavaScript are doomed.
Admin
For the record, JSON serialization is a solved problem in Java. At most, it should take a handful of annotations to configure things like polymorphism or behavior on unknown properties, occasionally to register a custom (de)serializer if you need to match some quirky API or something.
Admin
🤡 Why use objects when you can pass around your data as strings? 🤡
Admin
Exactly. That way you can spawn off sed or awk to modify arbitrary field values easily. Always use the proper tool for the job.
Admin
OMG - flashbacks to when I had to use Java and C# to work with JSON data <shudder>
Admin
Pretty sure I know why this code happened. Method serializeSpecialFloatingPointValues tells the tale. Special floating point values and their presence is why things can break various hilarious ways.
Apparently, Charge can be one of special values that are banned by JSON specification, but GSON can produce "bad" JSON if you enable them.
So that's why they feed JSON that can contain special values into GSON to generate JSON with particular way to record them in resulting JSON. Since authors need JsonObje2ct then they get string representation for reparsing it back into JsonObject.
Most likely they use same and similar approach everywhere else thus dependency on particular way special values of float are written.
Admin
Divide and unit test!
Admin
Frist reaction: how is GSON different from JSON?
Second reaction: maybe I don't want to know.
It works, right? Ignorance is bliss.
Admin
https://github.com/google/gson