-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
At the moment, results are returned as a regular hash, with keys and values containing a mix of strings and symbols:
{"nature"=>:archive, "intrinsics"=>nil, "entries"=>[{:type=>:file, :size=>53335, :filename=>"foo"}, {:type=>:file, :size=>292210, :filename=>"bar"}, {:type=>:file, :size=>1965044, :filename=>"baz"}], "format"=>:zip}
It happened to me several times that I was getting the key or comparing the value using the wrong type. I think normalising the return value of as_json
would be a nice improvement.
Currently, I am doing this to normalise the result hash:
JSON.load(JSON.dump(result))
Here are the options I see:
- use strings or symbols for all key/values (since this is meant to serialise to JSON at some point, it might make sense to stick to strings)
- use a hash with indifferent access; however, that likely adds a dependency and diverts from the idea of having a very strict contract and the least number of dependencies
Metadata
Metadata
Assignees
Labels
No labels