File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,10 @@ def configure(opts)
290
290
end
291
291
alias merge configure
292
292
293
+ def allow_duplicate_key? # :nodoc:
294
+ @allow_duplicate_key
295
+ end
296
+
293
297
# Returns the configuration instance variables as a hash, that can be
294
298
# passed to the configure method.
295
299
def to_h
@@ -491,9 +495,18 @@ def json_transform(state)
491
495
delim = ",#{ state . object_nl } "
492
496
result = +"{#{ state . object_nl } "
493
497
first = true
498
+ key_type = nil
494
499
indent = !state . object_nl . empty?
495
500
each { |key , value |
496
- result << delim unless first
501
+ if first
502
+ key_type = key . class
503
+ else
504
+ if key_type && !state . allow_duplicate_key? && key_type != key . class
505
+ key_type = nil # stop checking
506
+ JSON . send ( :on_mixed_keys_hash , self , state . allow_duplicate_key? == false )
507
+ end
508
+ result << delim
509
+ end
497
510
result << state . indent * depth if indent
498
511
499
512
if state . strict? && !( Symbol === key || String === key )
You can’t perform that action at this time.
0 commit comments