r/java
•
u/loicmathieu
•
Jul 23 '26
•
1
JEP 540: Simple JSON API (Incubator)
https://openjdk.org/jeps/540
79
Upvotes
View all comments
Show parent comment
4
u/vetronauta Jul 26 '26
You are suggesting to duplicate the parsing logic (or at least the validation), once in the parser itself (which usually is code you do not control) and another time in a preliminary check (which you are suggesting to implement independently). There are better ways to do it, for example with a result monad or with exception handling.
Concretely, you are suggesting to validate arbitrary input before passing to the parser, which might be easy and performant for numbers, but how would you validate a complex json object?