Creating this array format
I need help in creating a json sting in the following format.
[{"k开发者_StackOverflow社区ey": "hello world", "value": "hello world"}, {"key": "movies", "value": "movies"}, {"key": "ski", "value": "ski"}, {"key": "snowbord", "value": "snowbord"}]
my input data will be categories with following attributes.
:id, :name, :active
and I would like to use the :id as key and :name as value.
input_data.map { |d| { "key" => d.id, "value" => d.name } }
精彩评论