mardi 20 janvier 2015

Ruby and repeat an action on each entry of a JSON array


Vote count:

0




What is the best way to repeat an action for each entry of a JSON array ?


I have the following JSON :



{
"entries": [
{
"key": "population",
"value": "98"
},
{
"key": "stuff",
"value": "18"
}
]
}


And I would like to call a method on each entry, for example :



Log.create(key: 'stuff', value: '18')


But I have no idea of how I could to that in a clean way (not to much hacky code).


Thanks.



asked 1 min ago

Simon

145






Ruby and repeat an action on each entry of a JSON array

Aucun commentaire:

Enregistrer un commentaire