Towards a JSON API for the JDK

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed May 21 17:25:17 UTC 2025


On 21/05/2025 18:06, Paul Sandoz wrote:
> It was a design choice to be consistent with each json value having an
> X, accepting X in on construction and producing X out (notionally) on
> deconstruction, which leans into pattern matching. Definitely pros/cons
> to that e.g., we could instead make JonObject implement Map, or do as
> you suggest [*], both of which adjust how one reasons about the X in and
>   X out.

I agree with this. When I wrote, I thought that it might be possible to 
address some of these use cases using instance pattern declaration on 
the array class (e.g. having an instance pattern that extracts the i-th 
element of a JSONArray) -- but the instance pattern proposals we have 
discussed so far [1] are not powerful enough to model that use case.

Maurizio

[1] - 
https://openjdk.org/projects/amber/design-notes/patterns/towards-member-patterns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250521/3ab6f27e/attachment-0001.htm>


More information about the core-libs-dev mailing list