Skip to content

Commit 9cf5d0b

Browse files
committed
Fix Time serialization regression introduced by dropping MultiJson
JSON.dump bypasses ActiveSupport's Hash#to_json override, causing Time values to serialize via Time#to_s ("2026-04-16 10:55:10 UTC") instead of ActiveSupport's as_json ("2026-04-16T10:55:10.597Z"). Replace Json.dump with Hash#to_json which properly delegates through ActiveSupport and remove the now-unused Grape::Entity::Json constant. Fixes #403
1 parent a4e3fcd commit 9cf5d0b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/grape_entity/entity.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'multi_json'
4-
53
module Grape
64
# An Entity is a lightweight structure that allows you to easily
75
# represent data from your application in a consistent and abstracted
@@ -594,7 +592,13 @@ def is_defined_in_entity?(attribute)
594592

595593
def to_json(options = {})
596594
options = options.to_h if options&.respond_to?(:to_h)
595+
<<<<<<< HEAD
597596
MultiJson.dump(serializable_hash(options))
597+
||||||| parent of 374a021 (Fix Time serialization regression introduced by dropping MultiJson)
598+
Grape::Entity::Json.dump(serializable_hash(options))
599+
=======
600+
serializable_hash(options).to_json
601+
>>>>>>> 374a021 (Fix Time serialization regression introduced by dropping MultiJson)
598602
end
599603

600604
def to_xml(options = {})

0 commit comments

Comments
 (0)