Method: JSI::Base::HashNode#as_json
- Defined in:
- lib/jsi/base/node.rb
#as_json(options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/jsi/base/node.rb', line 94 def as_json( = {}) hash = {} each_key do |k| ks = k.is_a?(String) ? k : k.is_a?(Symbol) ? k.to_s : k.respond_to?(:to_str) && (kstr = k.to_str).is_a?(String) ? kstr : raise(TypeError, "JSON object (Hash) cannot be keyed with: #{k.pretty_inspect.chomp}") hash[ks] = jsi_child_node(k).as_json(**) end hash end |