From b094ee3f23097f3e02c54476a0499e590e1bf5d7 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 28 Oct 2024 08:34:43 +0100 Subject: Handle all formatting configs potentially being `nil`. Fix: https://github.com/ruby/json/issues/653 I don't think this was really fully supported in the past, but it kinda worked with some of the implementations. --- lib/json/ext/generator/state.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/json') diff --git a/lib/json/ext/generator/state.rb b/lib/json/ext/generator/state.rb index 4f9675d7b5..29688142f0 100644 --- a/lib/json/ext/generator/state.rb +++ b/lib/json/ext/generator/state.rb @@ -46,15 +46,15 @@ module JSON opts.each do |key, value| case key when :indent - self.indent = value + self.indent = value || '' when :space - self.space = value + self.space = value || '' when :space_before - self.space_before = value + self.space_before = value || '' when :array_nl - self.array_nl = value + self.array_nl = value || '' when :object_nl - self.object_nl = value + self.object_nl = value || '' when :max_nesting self.max_nesting = value || 0 when :depth -- cgit v1.2.3