On Mon, 10 Aug 2026 17:36:35 GMT, Naoto Sato <[email protected]> wrote:

> This PR implements [JEP 540: Simple JSON API 
> (Incubator)](https://openjdk.org/jeps/540).
> 
> It adds the `jdk.incubator.json` module which provides APIs for reading and 
> writing JSON documents as specified by [RFC 
> 8259](https://datatracker.ietf.org/doc/html/rfc8259). This is an incubating 
> API.
> 
> API documentation: 
> https://cr.openjdk.org/~naoto/json/javadoc/api/jdk.incubator.json/module-summary.html
> Co-authored-by: Justin Lu 
> ([@justin-curtis-lu](https://github.com/justin-curtis-lu))
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/jdk.incubator.json/share/classes/jdk/incubator/json/JsonValue.java line 101:

> 99:  *     {@code long} if its numeric value can be represented exactly.</li>
> 100:  *     <li>{@code asDouble()} converts a {@code JsonNumber} instance to 
> a Java
> 101:  *     {@code double} if its numeric value can be represented 
> accurately.</li>

You addressed my previous comment about JsonNumber::asDouble doing the 
conversion with Double.parseDouble and rounding to the nearest representable 
double. I'm just wondering now about the class description where it uses 
"represented accurately" as it seems to conflict.

src/jdk.incubator.json/share/classes/jdk/incubator/json/package-info.java line 
63:

> 61:  * These methods produce String representations of a {@code JsonValue}.
> 62:  * The returned text adheres to the JSON grammar defined in RFC 8259.
> 63:  * {@code JsonValue.toString()} produces the most compact representation 
> which does not

Is "the most compact representation" accurate? JsonValue says "a compact 
representation". I'm thinking cases like `JsonNumber.of("1.0").toString()` 
generates "1.0" rather than "1".

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32282#discussion_r3784565241
PR Review Comment: https://git.openjdk.org/jdk/pull/32282#discussion_r3784757541

Reply via email to