Created
January 28, 2016 14:50
-
-
Save mlomnicki/2f2accf96755a0a6eee9 to your computer and use it in GitHub Desktop.
JSON + OpenStruct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'ostruct' | |
data = '{"a": {"b": 1}}' | |
result = JSON.parse(data, object_class: OpenStruct) | |
result.a.b # => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
❤️