I'm currently implementing a JSON based Grape API. I've integrated roar for JSON serailization and deserialization. When executing the following code, it seems that the JSON is encoded twice resulting a response with slashes. Is there anyway on Grape to suppress the JSON decode when required?
json = UserRepresenter.new(user).to_json
{ status: StatusResponse::VALID, message: json }
Grape automatically encodes the output as JSON (when
format :json
is specified) so theto_json
call in your code is superfluous.Try changing your code to simply this: