JEP 540: Simple JSON API (Now in Incubator)
11–20 of 83 posts
Re: JEP 540: Simple JSON API (Now in Incubator)
#12 IO.println(JsonObject.of(Map.of("providers",
JsonArray.of(List.of(JsonString.of("SUN"),
JsonString.of("SunRsaSign"),
JsonString.of("SunEC"))))));
There's gotta be a better way!Surely there could be some way of creating a JsonArray of native Java Strings, Booleans, Doubles, and Integers without requiring clients to explicitly convert each value into a JsonValue. And why am I forced to convert a native List into a JsonArray just so I can make it the value of a JsonObject?
Why can't I write this?
JsonObject.of(Map.of("providers", List.of("SUN", "SunRsaSign", SunEC"))));Re: JEP 540: Simple JSON API (Now in Incubator)
#13Many languages have json marshalling and unmarshalling in their standard libs, e.g. C#, golang, python.
Re: JEP 540: Simple JSON API (Now in Incubator)
#14Happy to see that numbers are arbitrary width/precision until explicitly cast by the user. This goes against so many other JSON libraries that will always cast all numbers to double (or even float) thereby silently corrupting JSON numbers representing large values (eg. memory addresses). Does anyone know how this behaves when encountering a repeated key in an object? (RFC8259 states that keys SHOULD be unique, which…
Duplicate keys are a parse exception.
> Additionally, documents must not have objects with duplicate member names.
Re: JEP 540: Simple JSON API (Now in Incubator)
#15Re: JEP 540: Simple JSON API (Now in Incubator)
#16A stated goal of the API is to have "low ceremony"; this seems like a lot of ceremony. IO.println(JsonObject.of(Map.of("providers", JsonArray.of(List.of(JsonString.of("SUN"), JsonString.of("SunRsaSign"), JsonString.of("SunEC")))))); There's gotta be a better way! Surely there could be some way of creating a JsonArray of native Java Strings, Booleans, Doubles, and Integers without requiring clients to explicitly conve…
(println (json/generate-string {:providers ["SUN" "SunRsaSign" "SunEC"]}))Re: JEP 540: Simple JSON API (Now in Incubator)
#17Meanwhile, Jackson has been going strong for almost 20 years now https://github.com/FasterXML/jackson . One of my favorite things about Jackson was being able to arbitrarily navigate through the document with a rich and fluent API (JsonNode) in jackson.databind, which this JEP at least conceptually borrows from with the JsonValue abstraction. Both of these are better than how some of the other implementations do it,…
Re: JEP 540: Simple JSON API (Now in Incubator)
#18It used to be the case that if you wanted to build a web service on the JVM, you wanted 2 things: 1. An HTTP server library/framework 2. A JSON library We got a decently-performing and unopionated HTTP server in JDK 18 with "HttpHandlers" and "SimpleFileServer" plus "jwebserver" CLI It later received Virtual Thread support, which made performance + scalability very competitive. With a JSON module, you finally won't N…
A web server using this could only start parsing when it receives the last byte, and could only start responding when it’s done serializing, all while holding non-lazy trees of JsonValue objects in memory.
Re: JEP 540: Simple JSON API (Now in Incubator)
#19Using JSON as a configuration format is a big mistake. JEP authors could learn a bit from package.json problems. Hope JSON will not be used in anything significant for JDK configuration.
I'm somewhat boggled that json5 hasn't grown to be more of a thing.
Re: JEP 540: Simple JSON API (Now in Incubator)
#20A stated goal of the API is to have "low ceremony"; this seems like a lot of ceremony. IO.println(JsonObject.of(Map.of("providers", JsonArray.of(List.of(JsonString.of("SUN"), JsonString.of("SunRsaSign"), JsonString.of("SunEC")))))); There's gotta be a better way! Surely there could be some way of creating a JsonArray of native Java Strings, Booleans, Doubles, and Integers without requiring clients to explicitly conve…