fast_jsonapi: Regression: Date/Time is no longer serialized as ISO8601

I upgraded from 1.0.17 to 1.1.1 and somewhere (likely #58) the way date/timestamps are serialized regressed from being ISO8601 strings to simple time strings. Luckily my serializer specs caught it.

-      "created_at": "2018-03-22T09:45:00.246Z",
-      "updated_at": "2018-03-22T09:45:00.246Z",
+      "created_at": "2018-03-22 09:45:00 UTC"
+      "updated_at": "2018-03-22 09:45:00 UTC",

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Before installing oj

[1] pry(main)> FastJsonapi::MultiToJson.to_json_method
=> "def _fast_to_json(object)\n JSON.fast_generate(object, create_additions: false, quirks_mode: true)\nend"
...
[5] pry(main)> FastJsonapi::MultiToJson.to_json(@boat)
D, [2018-08-21T13:05:43.217843 #13519] DEBUG -- : Defining FastJsonapi::MultiToJson._fast_to_json as "def _fast_to_json(object)\n JSON.fast_generate(object, create_additions: false, quirks_mode: true)\nend"
=> "\"#<Boat:0x00007ff5aaa949b0>\""

After installing oj

[1] pry(main)> FastJsonapi::MultiToJson.to_json_method
=> "def _fast_to_json(object)\n ::Oj.dump(object, mode: :compat, time_format: :ruby, use_to_json: true)\nend"
...
[7] pry(main)> FastJsonapi::MultiToJson.to_json(@boat)
D, [2018-08-21T13:03:25.941746 #13304] DEBUG -- : Defining FastJsonapi::MultiToJson._fast_to_json as "def _fast_to_json(object)\n ::Oj.dump(object, mode: :compat, time_format: :ruby, use_to_json: true)\nend"
=> "{\"id\":1,\"name\":\"Dratini\",\"created_at\":\"2018-08-17T14:16:30.115Z\",\"updated_at\":\"2018-08-17T14:16:30.115Z\",\"booking_system_id\":1,\"company_id\":1,\"location_id\":1,\"boat_model_id\":1,\"year\":3672}"