r/java
•
u/loicmathieu
•
Jul 23 '26
•
1
JEP 540: Simple JSON API (Incubator)
https://openjdk.org/jeps/540
79
Upvotes
View all comments
5
u/aoeudhtns Jul 23 '26 edited Jul 23 '26
I just wrote my own little parser of a somewhat uncommon config language relevant to a project of mine and modeled it very similarly to this; it's really nice to see Java's DOP features coming together.
I noticed that
JsonNumberhas static conveniences in theof()methods for different types, including parsing a String.I wonder if there's something similar that could be for
JsonArrayand/orJsonObject. MaybeOr, more implementation-heavy but also potentially useful:
Perhaps the
transformmethod (if not in name, in spirit) could dangle somewhere off the supertype. This would make the API even simpler to use as the explicit conversions aren't as strictly necessary unless the developer intends them to be or needs absolute control. This example:Could become, if JsonObject had a similar method in addition to JsonArray: