Open rmannibucau opened 6 years ago
I think there was a similar question about Date/Time. These types are not in the JSON standard (RFC) so while JSON-B provides out of the box mapping to certain types it does not seem covered by the standard. @m0mus WDYT about this?
@keilw issue is not in jsongenerator or components like that but jsonobjectbuilder which is java first so jsonobjectbuilder should provide a stronger typing than json and lower level components IMHO.
@rmannibucau I'm talking about JsonObjectBuilder
which is only creates a JsonObject
right now.
Do you suggest to add methods like
JsonObjectBuilder add(String name, LocalDateTime value);
or similar?
Not sure, if this fits in a lower level API, but @m0mus has to say, how he feels it should evolve if any beyond the JSON specification.
In that specification types like Date/Time (https://www.w3schools.com/js/js_json_datatypes.asp) are still unsupported. Since XML Schema is also used alongside JAXB primarily to bind new data types defined in that schema, I am not sure, if JSON Schema and this spec make sense together. It does feel very well suited for JSON-B.
Well, the builder is an awesome api to
Only issue is it misses some type info so would be great to fill the gap to avoid another api on top of it
The thing is there IS another API on top of that JSON-B. I leave it to @m0mus what aspects to add or cover here, some I have the feeling belong to JSON-B, and it is up to users if they are happy with low-level functionality of the strict JSON standard or want a richer type-system.
@keilw no, JSON-B doesnt overlap this use case at all, the opposite is true, enhacing jsonp to support that would benefit json-b but the opposite will not.
@m0mus WDYT, does it belong here or rather JSON-B?
Based on the intro example, it would be something like
// Create Json and serialize
JsonObject json = Json.createObjectBuilder()
.add("name", "Falco")
.add("age", BigDecimal.valueOf(3))
**.add("dob", LocalDate.of(1957, 2, 19))**
.add("biteable", Boolean.FALSE).build();
String result = json.toString();
I'm fine to add it to JSONP.
JsonObjectBuilder is a very convenient API and has the advantage in current form to not loose immediately the format of the underlying data (BigDecimal/BigInteger, long, ....). However I think it should cover what developpers consider as "primitives". To be accurate I think we can use json schema specification as a basis.
What is missing IMO is:
The most important (and urgent) item is likely about the dates but longer term it would be very good to have an API allowing users or implementations to generate a schema from the builder API transparently (just decorating the default implementations).