Towards a JSON API for the JDK
David Vidal Escudero
david.vidal.escudero at gmail.com
Tue May 20 23:47:21 UTC 2025
Hello,
So, if such a Json library is added to the JDK, the Java Http module now
should accept a JsonDocument implementing something like
BodyPublishers.ofJsonDocument, or better yet BodyPublishers.ofJsonEncodable
(assuming Eteh proposal).
I think also JDBC API should be modified so prepared statements can
implement .setJson and .getJson for DBMS supporting Json type (like
Postgres).
David.
---------- Forwarded message ---------
De: Paul Sandoz <paul.sandoz at oracle.com>
Date: mar, 20 de may de 2025, 14:46
Subject: Re: Towards a JSON API for the JDK
To: Swaranga Sarma <sarma.swaranga at gmail.com>
Cc: Remi Forax <forax at univ-mlv.fr>, Brian Goetz <brian.goetz at oracle.com>,
core-libs-dev <core-libs-dev at openjdk.org>
Data binding is a complex feature, even if some examples make it appear
simple. Our intention is to explore alignment with the serialization 2.0
effort, when we are ready to so. Hence, I would urge folks to be patience
and watch out Brian and Viktor’s Devoxx 2024 talk on the topic.
Paul.
> On May 20, 2025, at 12:21 PM, Swaranga Sarma <sarma.swaranga at gmail.com>
wrote:
>
> > A potential advantage that we (the OpenJDK community) can more easily
do is devise an API that resonates with direction the Java platform is
heading, specifically around the pattern matching and serialization 2.0
>
> Right, but most of the discussion here seems to be on the low level tree
API and how one might navigate it (perhaps using pattern matching). I am
not seeing any discussion on the serialization/deserialization or any
reasoning why that is not the goal of the new JEP. Basically a very focused
and narrow API:
>
> ```
> var jsonStr = "..."
> var myRecord = Json.deserialize(jsonString, UserRecord.class); //and a
few other variants
> var serialized = Json.serialize(myRecord)
> ```
>
> This leaves the tree API open to reimplementation later when pattern
matching and other features are firmly in place in the JDK. I am making a
case that this would be more immediately useful for the most common and
simpler cases.
>
>
> Regards
> Swaranga
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250520/a6540bde/attachment.htm>
More information about the core-libs-dev
mailing list