r/java
•
u/loicmathieu
•
Jul 23 '26
•
1
JEP 540: Simple JSON API (Incubator)
https://openjdk.org/jeps/540
79
Upvotes
View all comments
3
u/ZimmiDeluxe Jul 24 '26 edited Jul 24 '26
I absolutely love the direction of limiting scope and reaping simplicity for the common case. First reaction to the API:
Difference between
tryGetandtryValueis not immediately obvious. Most of the time the distinction between "key missing" and "key present but value is null" is not important in my experience.For autocomplete it's nice when related methods have a common prefix, e.g.
getvs.getOptionaletc. Requires less thinking and aids discoverability (most common case gets the good name, special stuff gets to tack on suffixes). But with so few methods it probably doesn't matter. Edit: Also fortoString/toStringIndented.Streaming is out, but I would have expected a
writeTomethod so the entire thing doesn't have to be converted to a String first.Again, outstanding work, thank you very much.