我有以下 JSON -Structure:
{ "A" : "1", "B" : "2", "RandomOtherName" : "54738" }
如何在ruby中提取关键值("A"
,"B"
,"RandomOtherName"
,...)(最好是在数组中)?
答案 0 :(得分:6)
require 'json'
data = '{ "A" : "1", "B" : "2", "RandomOtherName" : "54738" }'
JSON.parse(data).keys # => ["A", "B", "RandomOtherName"]