instance method
Symbol#to_json
(?::JSON::State? state) -> ::String
to_json(state = nil, *a)
ext/json/lib/json/add/symbol.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ext/json/lib/json/add/symbol.rb, line 39
def to_json(state = nil, *a)
state = ::JSON::State.from_state(state)
if state.strict?
super
else
as_json.to_json(state, *a)
end
end
Returns a JSON string representing self:
Example
require 'json/add/symbol' puts :foo.to_json
Output:
Example
# {"json_class":"Symbol","s":"foo"}