Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing Hashie::Mash output to Json in ruby

I'm getting user input in JSON format for an API created using grape. In a particular parameter, I'm giving an array of JSON in the following format.

 "personal" : {
  "details" : {
   "firstname" :"nagalakshmi",
   "lastname" : "n"
  }
}

When I tried to print "personal" attribute it is showing like below

#<Hashie::Mash details=#<Hashie::Mash firstname="nagalakshmi" lastname="n">>

Is there any way to parse the attribute to json format?

like image 991
NagaLakshmi Avatar asked Mar 22 '23 02:03

NagaLakshmi


1 Answers

I was able to do it using to_json

like image 90
NagaLakshmi Avatar answered Mar 24 '23 17:03

NagaLakshmi