Advertisement
Guest User

Untitled

a guest
Jun 4th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. This is my object, we'll call it "some_hash":
  2. {
  3. "object1": {["key1.1","key1.2"]=>["1","2","3"],["key2.1","key2.2"]=>["1","2","3"],["key3.1","key3.2"]=>["1","2","3"]}
  4. "object2": [["1","2","3"],["1","2","3"],["1","2","3"]]
  5. }
  6.  
  7. And:
  8. some_hash["object1"].keys
  9. Gives:
  10. [["key1.1", "key1.2"], ["key2.1", "key2.2"], ["key3.1", "key3.2"]]
  11.  
  12. However:
  13. JSON.parse(JSON.generate(some_hash))["object1"].keys
  14. Gives:
  15. ["[\"key1.1\", \"key1.2\"]", "[\"key2.1\", \"key2.2\"]", "[\"key3.1\", \"key3.2\"]"]
  16.  
  17. The keys are now strings instead of arrays.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement