6

I have the following JSON-Structure:

{ "A" : "1", "B" : "2", "RandomOtherName" : "54738" }

How can I extract the key values ("A", "B", "RandomOtherName",...) in ruby (Preferably in to an array)?

1 Answer 1

13
require 'json'
data = '{ "A" : "1", "B" : "2", "RandomOtherName" : "54738" }'
JSON.parse(data).keys # => ["A", "B", "RandomOtherName"]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.