Method: String#as_json

Defined in:
lib/openc3/io/json_rpc.rb

#as_json(_options = nil) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/openc3/io/json_rpc.rb', line 60

def as_json(_options = nil)
  as_utf8 = self.dup.force_encoding('UTF-8')
  if as_utf8.valid_encoding?
    if as_utf8 =~ NON_UTF8_PRINTABLE
      return self.to_json_raw_object
    else
      return as_utf8
    end
  else
    return self.to_json_raw_object
  end
end