# Convert json string to hash and retrieve hash items values in ruby

**URL:** <https://www.ruby-forum.com/t/convert-json-string-to-hash-and-retrieve-hash-items-values-in-ruby/240992>\
**Category:** Rails\
**Created:** [May 8, 2014, 5:55pm UTC](https://www.ruby-forum.com/t/convert-json-string-to-hash-and-retrieve-hash-items-values-in-ruby/240992 "2014-05-08T17:55:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [May 8, 2014, 5:55pm UTC](https://www.ruby-forum.com/t/convert-json-string-to-hash-and-retrieve-hash-items-values-in-ruby/240992/1 "2014-05-08T17:55:23Z")

</div>

I have a string object which is basically in a json format and while  
trying to print it shows in console as

```
item =
 {
        "id": "4c9f83e4-f479-48d0-9f92-3fff70a8f6ba",
         "item":

```

“{“business”:“1114”,“class”:“Demo”,“date”:“01-01-2014”,“version”:”",“data”:“dummy”,“name”:“Finance”}"

```
    }

```

I need to get the values of business, class, date etc and pass it as  
params  
to my method. So I tried to convert it into hashes as below

```
hash_item = JSON.parse (item)

```

and output in console shows as

```
The converted hash item is
{"guid"=>"4c9f83e4-f479-48d0-9f92-3fff70a8f6ba",

```

“item”=\>"{“business”:“1114”,“service\_class”:“DataServicesBalancesRaw”,“start\_date”:“2014-05-08”,“calc\_version”:"",“data”:“8b698df0-3673-4057-b71a-080d254c355d^^”,“queue\_name”:“high”}"}

But when I try to access the hash value for business as  
`hash_item['item']['business']` it shows

> “business”

since the value of item is a String in the hash\_item. I am not sure  
whether my approach is correct or not. So is there any better idea or  
any  
inputs to retrieve the hash values . Please help.
