On Mon, 31 Aug 2026 21:58:17 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)), Stuart Marks 
>> ([@stuart-marks](https://github.com/stuart-marks)) 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Naoto Sato has updated the pull request incrementally with nine additional 
> commits since the last revision:
> 
>  - Merge remote-tracking branch 'jdk-sandbox/json' into 
> JDK-8381976-Implementation-for-Simple-JSON-API
>  - offset -> cursorPos in JsonParser
>  - Consolidated copyOf() in JsonArrayImpl constructor
>  - Make Utils.composeTypeError derive expected from Class name
>  - Refactor Frame classes in JG into records
>  - Give initial size to StringBuilder
>  - initSb() -> StringBuilder::new
>  - Making Util class final
>  - Clarify JSON string -> text in toDisplayString

src/jdk.incubator.json/share/classes/jdk/incubator/json/impl/JsonParser.java 
line 67:

> 65:     private static final class ObjectContainer implements Container {
> 66:         final int startOffset;
> 67:         final Map<String, JsonValue> members = new LinkedHashMap<>();

This could be a SequencedMap, which might help clarify where we're preserving 
order.

This would allow writing putLast() instead of put() at line 258 below.

However, it would require creating a new, empty LinkedHashMap in the 
JsonObject.of() factory method. Or to create such an empty LHM and cache it for 
reuse. But see also my comment there.

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

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

Reply via email to