From 9cf5d0b48a9ecd0dca4f1373a4b649679b0d663e Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Fri, 17 Apr 2026 05:53:50 +0200 Subject: [PATCH 1/3] 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 --- lib/grape_entity/entity.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/grape_entity/entity.rb b/lib/grape_entity/entity.rb index cd14033..ef8625d 100644 --- a/lib/grape_entity/entity.rb +++ b/lib/grape_entity/entity.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'multi_json' - module Grape # An Entity is a lightweight structure that allows you to easily # represent data from your application in a consistent and abstracted @@ -594,7 +592,13 @@ def is_defined_in_entity?(attribute) def to_json(options = {}) options = options.to_h if options&.respond_to?(:to_h) +<<<<<<< HEAD MultiJson.dump(serializable_hash(options)) +||||||| parent of 374a021 (Fix Time serialization regression introduced by dropping MultiJson) + Grape::Entity::Json.dump(serializable_hash(options)) +======= + serializable_hash(options).to_json +>>>>>>> 374a021 (Fix Time serialization regression introduced by dropping MultiJson) end def to_xml(options = {}) From 09ed8beac121360519fa8c33a47d46bc6d7929ab Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Fri, 17 Apr 2026 06:39:09 +0200 Subject: [PATCH 2/3] Add CHANGELOG entry for #404 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98b796c..5cb5463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Fixes * Your contribution here. +* [#404](https://github.com/ruby-grape/grape-entity/pull/404): Drop `MultiJson` dependency, use `Hash#to_json` for ActiveSupport-aware serialization - [@numbata](https://github.com/numbata). ### 1.0.4 (2026-04-17) From 7c577c8e3bc6b538be56ac963de3ed90200a96a7 Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Fri, 17 Apr 2026 06:44:50 +0200 Subject: [PATCH 3/3] Resolve merge conflicts with hotfix and drop multi_json dependency --- grape-entity.gemspec | 1 - lib/grape_entity/entity.rb | 6 ------ 2 files changed, 7 deletions(-) diff --git a/grape-entity.gemspec b/grape-entity.gemspec index 5b158df..b6b882b 100644 --- a/grape-entity.gemspec +++ b/grape-entity.gemspec @@ -25,7 +25,6 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 3.0' s.add_dependency 'activesupport', '>= 3.0.0' - s.add_dependency 'multi_json', '>= 1.0' s.files = Dir['lib/**/*.rb', 'CHANGELOG.md', 'LICENSE', 'README.md'] s.require_paths = ['lib'] diff --git a/lib/grape_entity/entity.rb b/lib/grape_entity/entity.rb index ef8625d..bd36d20 100644 --- a/lib/grape_entity/entity.rb +++ b/lib/grape_entity/entity.rb @@ -592,13 +592,7 @@ def is_defined_in_entity?(attribute) def to_json(options = {}) options = options.to_h if options&.respond_to?(:to_h) -<<<<<<< HEAD - MultiJson.dump(serializable_hash(options)) -||||||| parent of 374a021 (Fix Time serialization regression introduced by dropping MultiJson) - Grape::Entity::Json.dump(serializable_hash(options)) -======= serializable_hash(options).to_json ->>>>>>> 374a021 (Fix Time serialization regression introduced by dropping MultiJson) end def to_xml(options = {})