RISCfuture / dropbox

An easy-to-use client library for the official Dropbox API.
MIT License
519 stars 47 forks source link

An option to return hashes instead of structs #40

Open jgonera opened 13 years ago

jgonera commented 13 years ago

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?

victorbstan commented 13 years ago

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
jgonera commented 13 years ago

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