Hi Tatu,

Thank you for your work on Jackson.

Could I propose date/time classes (in particular java.time.*) serialise as 
RFC 3339 / ISO 8601 interchange format by default for Jackson 3, and not as 
an epoch second, milli, micro or nano, etc.

It is the recommended practice by many in the industry (E.g. Google / 
Microsoft / json-schema validation, see links below) that RFC 3339 / ISO 
8601 be used for the serialisation format for date/times in JSON and in 
particular JSON REST API design.

It is also generally the default format used by java.time.* .toString() and 
.parse() methods.

RFC 3339 / ISO 8601, I would say, is a better format than an epoch as

   - it is human readable
   - can preserve timezone information
   - has nano precision
   - has a maximum timestamp value that is not limited by the bit-length of 
   a double/long (platform specific) and
   - does not have unambiguous precision when inspecting the value 
   (milli/micro, etc).

Additionally, is a more intuitive format for serialising LocalDate, rather 
than the current default of a JSON numeric array of [year, month, day]

Speaking from my experience, its seems a common source of bugs for 
developers not realising that either overriding global config defaults 
(e.g. disable SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) or field 
level annotations (@JsonFormat(shape = STRING)) are necessary (or possible) 
to serialise as such. 

Other frameworks may for instance try to do this already, for example Spring 
Boot's JacksonAutoConfiguration 
<https://github.com/spring-projects/spring-boot/blob/v2.7.0/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java#L88>
 
does this by default.

I did see JSTEP-2: Changes to date/time defaults 
<https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-2#changes-to-datetime-defaults>
 
and JSTEP-5: Unify Date/Time handling 
<https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-5> but it 
seems it hadn't come to a firm conclusion what the default behaviour for 
date time serialisation in Jackson should be.

Thanks for your consideration.

References which consider RFC 3339 / ISO 8601 for datetime:

   - Google JSON style guide - Date Time Property values 
   
<https://google.github.io/styleguide/jsoncstyleguide.xml#Property_Value_Data_Types>
   - Microsoft API guidelines - JSON serialisation of dates and times 
   
<https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#113-json-serialization-of-dates-and-times>
   - JSON Schema - dates and times 
   
<https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times>
   - API Stylebook - date time - Collection of other vendor Styleguides 
   <http://apistylebook.com/design/topics/data-format-date-time>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-dev/d30adc52-cc6a-4ac3-9e2d-862dff1f06d7n%40googlegroups.com.

Reply via email to