<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Paul Sandoz" <paul.sandoz@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"Brian Goetz" <brian.goetz@oracle.com>, "core-libs-dev" <core-libs-dev@openjdk.org><br><b>Sent: </b>Monday, May 19, 2025 10:02:50 PM<br><b>Subject: </b>Re: Towards a JSON API for the JDK<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote>
<div>On May 19, 2025, at 8:16 AM, Remi Forax <forax@univ-mlv.fr> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div>
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
<div>Okay,</div>
<div>i've taken a look to the design and this is not pretty.</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
That seems an exaggerated statement to me. It's a trade-off, a compromise, allowing others to implement their own parsers, perhaps from non-textual representations. So of course we cannot enforce certain constraints and we need to specify how implementations
 must behave.</div>
<div><br>
</div>
<div><br>
<blockquote>
<div>
<div>
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
<div>The main issue is that the javadoc claims that</div>
<div>  "Both <code>JsonValue</code> instances and their underlying values are immutable."</div>
<div>but at the same time any subtypes of JsonValue is non-sealed so anyone can implement let say JsonString and adds it's own mutable implementation.</div></div></div></div></blockquote></div></blockquote><div><br></div><div>You can not claim that JsonValue instances are immutable while obviously they are not.</div><div>You can not claim that JsonValue subtypes are ADTs while obviously JsonValue is not algebraic.</div><div><br data-mce-bogus="1"></div><div>You allow anybody to write their own class inside the JsonValue hierarchy, so there is no safety, strings can be not escaped correctly, number can represent invalid values, etc.</div><div><br data-mce-bogus="1"></div><div>The minute I write a method that takes a JsonValue as parameter i'm writing unsafe code, <br></div><div><br data-mce-bogus="1"></div><div>You are hoping that nobody will ever extend JsonValue subtypes, that's wishful thinking, this is not a safe design ... this is not pretty.</div><div><br data-mce-bogus="1"></div><div>Rémi</div><div><br data-mce-bogus="1"></div></div></div></body></html>