开发者

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 } }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜