class Object
Constants
- HTTP
Public Instance Methods
to_json()
click to toggle source
# File lib/android/json.rb, line 62 def to_json # The Android JSON API expects real Java String objects. @@fix_string ||= (lambda do |obj| case obj when String, Symbol obj = obj.toString when Hash map = Hash.new obj.each do |key, value| key = key.toString if key.is_a?(String) || key.is_a?(Symbol) value = @@fix_string.call(value) map[key] = value end obj = map when Array obj = obj.map do |item| (item.is_a?(String) || item.is_a?(Symbol)) ? item.toString : @@fix_string.call(item) end end obj end) obj = Org::JSON::JSONObject.wrap(@@fix_string.call(self)) if obj == nil raise "Can't serialize object to JSON" end obj.toString.to_s end