Last active
August 29, 2015 14:25
-
-
Save nando/2ae02aeefdc3784b37a5 to your computer and use it in GitHub Desktop.
user ids from Redmine's memberships JSON
This file contains hidden or 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' | |
json = <<JSON | |
{ | |
"memberships": [ | |
{ | |
"id": 3786, | |
"project": { | |
"id": 295, | |
"name": "Web Pública - UK" | |
}, | |
"user": { | |
"id": 83, | |
"name": "Miriam" | |
}, | |
"roles": [ | |
{ | |
"id": 3, | |
"name": "Jefe de proyecto" | |
} | |
] | |
}, | |
{ | |
"id": 4111, | |
"project": { | |
"id": 295, | |
"name": "Web Pública - UK" | |
}, | |
"user": { | |
"id": 157, | |
"name": "Beatriz" | |
}, | |
"roles": [ | |
{ | |
"id": 3, | |
"name": "Jefe de proyecto" | |
} | |
] | |
} | |
], | |
"total_count": 12, | |
"offset": 0, | |
"limit": 25 | |
} | |
JSON | |
hash = JSON.parse(json) | |
puts hash['memberships'].inject({}) {|sum, elem| sum[elem['user']['id']] = elem['user']['name']; sum} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment