7 ms·
The lack of an official JSON API has been a huge sore point for quite some time and has spawned dozens of libraries re-implementing the same thing over and over
by mmastrac 12y ago
The lack of an official JSON API has been a huge sore point for quite some time and has spawned dozens of libraries re-implementing the same thing over and over (GSON, Jackson, and even my own nanojson). I do hope that we avoid the DocumentBuilderFactory mistakes of XML and just end up with One True JSON implementation this time.
- jug6ernaut 12y agoIm not sure i would call having multiple options a huge sore point. Chances are many of these options would still exist even if there was an official API. FYI: Just looked at your nanojson, looks good. Might have to try it out, i like the fluent api for object creation.
- th3iedkid 12y ago>>Im not sure i would call having multiple options a huge sore point It becomes one when serializing and de-serializing across a distributed application like xerces class path issues in different jvm implementations.Not a common sore point though! >> Chances are many of these options would still exist even if there was an official API. True and agreed.
- carsongross 12y agoAre you sure that's true? As you say, look at the "standard" API for XML parsing: a complete disaster. Dates, similar. Logging was slightly less disastrous because they took so much from Log4j, but they still made it unwieldy enough that the log4j guys ended up writing an API on top of that which everyone uses. Now, props where props are due: Sun crushed the collections APIs compared to other languages at the time. And that more than makes up for everything else. But I see little evidence that standardizing JSON parsing will improve things.
- mmastrac 12y agoI'll counter that with saying that j.u.l is not actually that bad, IMO, although I might be the only one in the world that thinks that. I always just choose j.u.l in my projects because it works well-enough. I just shim anything with slf4j if it speaks log4j or commons-logging (shudder). Perhaps Sun should have just adopted slf4j and a simple console-logging stub, but I don't think j.u.l is really any worse than the alternatives -- only a different implementation. Now date APIs: those do suck, but I think the new Date JSR will finally get things to a place where we can use Java Dates rather than Joda.
- wlievens 12y agoXML parsers are so complicated because XML and the DOM are more complicated. A json parser can be simpler.
- sgarlatm 12y agoI really don't see any benefit of introducing a JSON API into the JDK. Jackson works great already. Are they really going to make something that much better?
- mdaniel 12y agoThere is an official JSON API: https://jcp.org/en/jsr/detail?id=353 https://jcp.org/en/jsr/detail?id=353 But it is unclear how many of the existing implementations conform to it, and it definitely doesn't work toward your misguided One True JSON Implementation goal.
- karianna 12y agoThat's a Java EE API. I've been working with the Java SE and Java EE folks to make sure that a new version of that will sit on top of the core JDK 9 one.
- mdaniel 12y agoHow did you arrive at the conclusion that a set of interfaces is a JavaEE API? Above and beyond the fact that in section 2.2 of the JSR it plainly states: "This JSR is targeted for Java SE 6 or higher and Java EE 7 or higher platforms."
- karianna 12y agoWe helped test out the RI and TCK - it was in the end up built for Java EE in mind (that's not to say someone couldn't provide a stripped down version that could work for SE - but I don't think anyone has or will).
- timmclean 12y agoGson worked perfectly for me a few years ago. Why did you end up implementing your own?
- jgalt212 12y agoAmen to that, brother. JSON is a huge pain point for Java. No wonder so many Java folks keep defending XML--at least it's malleable in their home language.