Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is my object, we'll call it "some_hash":
- {
- "object1": {["key1.1","key1.2"]=>["1","2","3"],["key2.1","key2.2"]=>["1","2","3"],["key3.1","key3.2"]=>["1","2","3"]}
- "object2": [["1","2","3"],["1","2","3"],["1","2","3"]]
- }
- And:
- some_hash["object1"].keys
- Gives:
- [["key1.1", "key1.2"], ["key2.1", "key2.2"], ["key3.1", "key3.2"]]
- However:
- JSON.parse(JSON.generate(some_hash))["object1"].keys
- Gives:
- ["[\"key1.1\", \"key1.2\"]", "[\"key2.1\", \"key2.2\"]", "[\"key3.1\", \"key3.2\"]"]
- The keys are now strings instead of arrays.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement