Public class methods
dump
(struct, io)
[show source]
# File lib/nwn/json_support.rb, line 28 28: def self.dump struct, io 29: d = if NWN.setting(:pretty_json) 30: ::JSON.pretty_generate(struct) 31: else 32: ::JSON.generate(struct) 33: end 34: io.puts d 35: d.size + 1 36: end
load
(io)
[show source]
# File lib/nwn/json_support.rb, line 16 16: def self.load io 17: json = if io.respond_to?(:to_str) 18: io.to_str 19: elsif io.respond_to?(:to_io) 20: io.to_io.read 21: else 22: io.read 23: end 24: 25: NWN::Gff::Struct.unbox!(JSON.parse(json), nil) 26: end