• (nodebb)

    This is also a good way to copy JSON files.

  • LZ79LRU (unregistered)

    This is the sort of situation where it's time to do a full rewrite either of the code or your CV.

  • TheCPUWizard (unregistered)

    Those who think there is a relationship between Java and JavaScript are doomed.

  • Naomi (unregistered)

    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.

  • Sauron (unregistered)

    🤡 Why use objects when you can pass around your data as strings? 🤡

  • efahl (unregistered) in reply to Sauron

    Exactly. That way you can spawn off sed or awk to modify arbitrary field values easily. Always use the proper tool for the job.

  • Tim R (unregistered)

    OMG - flashbacks to when I had to use Java and C# to work with JSON data <shudder>

  • Klimax (unregistered)

    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.

  • Erk (unregistered)

    Divide and unit test!

  • (nodebb)

    Frist reaction: how is GSON different from JSON?

    Second reaction: maybe I don't want to know.

    It works, right? Ignorance is bliss.

  • (nodebb) in reply to Ralf

    Frist reaction: how is GSON different from JSON?


    Gson is a Java library that can be used to convert Java Objects into their JSON representation.

Leave a comment on “Serialization and Deserialization”

Log In or post as a guest

Replying to comment #:

« Return to Article