JSON is Not Free in Java
In PHP and JavaScript, dealing with JSON is "free". It's a given. There are built-in functions that parse Strings into JSON and vice versa.
In Java, however, JSON is not free. It usually requires creating a bunch of objects that represent the data object described by the JSON. It also requires some kind of parsing library, like Jackson. It's a guarantee that there will always be a value for something, or it will be null.
However, sometimes JSON is tricky. The default parsers don't do well with empty objects.
A line like this in JSON gave me a hard time recently, whereas PHP and JavaScript would have been able to handle it just fine:
{
"ponyNames": {}
}
It turns out Jackson doesn't like parsing empty objects and arrays. I ended up using a custom parser, but that almost felt like it defeated the purpose of using a tool and JSON to begin with.
Anyways, it's not the end of the world, but it is a point for PHP and JavaScript - they have JSON handling handled much better.
Comments:
Leave a Comment
Submit