dropbox icon indicating copy to clipboard operation
dropbox copied to clipboard

An option to return hashes instead of structs

Open jgonera opened this issue 14 years ago • 2 comments

What is the reason behind converting all the data to structs? I actually find hashes better because I can encode them back to JSON easily. How about an option for API calls (or some general configuration setting) which would disable the hash to struct conversion?

jgonera avatar Aug 06 '11 12:08 jgonera

I'm using this patch:

# used to transform Structs from Dropbox to JSON
class Struct
  def to_map
    map = Hash.new
    self.members.each { |m| map[m] = self[m] }
    map
  end

  def to_json(*a)
    to_map.to_json(*a)
  end
end

victorbstan avatar Sep 27 '11 14:09 victorbstan

I'm doing something similar but still, it bothers me that there is a hash -> struct -> hash conversion.

jgonera avatar Sep 27 '11 16:09 jgonera