Ho un oggetto JSON con il seguente valore:
@value = {"val":"test","val1":"test1","val2":"test2"}
Voglio fare un giro in Ruby per ottenere le coppie chiave / valore. Quando lo uso @each
, non scorre attraverso l'oggetto perché non è nella forma hash Ruby:
@value = {"val"=>"test","val1"=>"test1","val2"=>"test2"}
Come posso convertire l'oggetto JSON sopra in un hash Ruby?
value = '{"val":"test","val1":"test1","val2":"test2"}'
avrebbe potuto essere più leggibile.