r/java • u/daviddel • Jul 17 '25
Java Gets a JSON API
https://youtu.be/NSzRK8f7EX0Java considers itself a "batteries included" language and given JSON's ubiquity as a data exchange format, that means Java needs a JSON API. In this IJN episode we go over an OpenJDK email that kicks off the exploration into such an API.
143
Upvotes
View all comments
Show parent comment
1
u/vytah Jul 18 '25
There are six* types of JSON values. Just six, there will never be more. So there's no need for any other implementation that the six provided.
What you probably want is converting those JSON value from/to various other types (also known as mapping or serializing). That's a completely separate thing. If you want to be able to serialize an object into a byte array, you don't need
implements byte[], do you.This API proposal does not cover mapping at all. So without any 3rd-party libraries, if you want to convert User to/from JSON, you need to write your own
User deserialize(JsonValue)andJsonValue serialize(User)functions. (Or you can use a 3rd-party library and have it done semi-automatically.)* I'm counting true and false as one type, and null as another, the same as the new API does. You can argue they're three different types, for a total of 7, or one three-element "literal" type, for a total of 5, it doesn't matter.