In my controller I have an instance variable and I am returning that
instance variable to json.erb file.
logger.info "The details of @employee is..#{@employee.body.inspect}"
The details of @employee is.."{\"date\"=>\"01-04-2012\",
“name”=>“David”, “empid”=>“E009”, “position”=>“10”,
“place”=>“noida”}
logger.info "The class of employee
is…#{@employee.body.class.inspect}"
The class of employee is...String
And I am returning it in json.erb file as
respond_with(@employee)
But in the json.erb file when I try to output it as
{
"details" : "<%[email protected]%>"
}
I am getting it as
{
"details": "{"date"=>"01-04-2012", "name"=>"David",
“empid”=>“E009”, “position”=>“10”, “place”=>“noida”}"
}
The output format I want it is in json format like below
{
"details": "{
"date" : "01-04-2012",
"name" : "David",
"empid" : "E009",
"position" : "10",
"place" : "noida"
}"
}
I tried several combinations and I am able to do it with eval. But it
seems to be some security issues using that. I am not good at regex
also.Please help