Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/json/truffle_ruby/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def generate(obj, anIO = nil)
!@ascii_only and !@script_safe and @max_nesting == 0 and (!@strict || Symbol === obj)
result = generate_json(obj, ''.dup)
else
result = obj.to_json(self)
result = +obj.to_json(self)
end
JSON::TruffleRuby::Generator.valid_utf8?(result) or raise GeneratorError.new(
"source sequence #{result.inspect} is illegal/malformed utf-8",
Expand Down Expand Up @@ -517,11 +517,11 @@ def json_transform(state)

if empty?
state.depth -= 1
return +'{}'
return '{}'
end

delim = ",#{state.object_nl}"
result = +"{#{state.object_nl}"
result = "{#{state.object_nl}"
first = true
key_type = nil
indent = !state.object_nl.empty?
Expand Down Expand Up @@ -558,7 +558,7 @@ def json_transform(state)
raise TypeError, "#{key.class}#to_s returns an instance of #{key_str.class}, expected a String"
end

result = +"#{result}#{key_json}#{state.space_before}:#{state.space}"
result = "#{result}#{key_json}#{state.space_before}:#{state.space}"
if state.strict? && !Generator.native_type?(value)
if state.as_json
value = state.as_json.call(value, false)
Expand Down Expand Up @@ -609,7 +609,7 @@ def json_transform(state)

if empty?
state.depth -= 1
return +'[]'
return '[]'
end

result = '['.dup
Expand Down Expand Up @@ -736,17 +736,17 @@ def to_json(state = nil, *args)

module TrueClass
# Returns a JSON string for true: 'true'.
def to_json(*) +'true' end
def to_json(*) 'true' end
end

module FalseClass
# Returns a JSON string for false: 'false'.
def to_json(*) +'false' end
def to_json(*) 'false' end
end

module NilClass
# Returns a JSON string for nil: 'null'.
def to_json(*) +'null' end
def to_json(*) 'null' end
end
end
end
Expand Down