ruby on rails - Format response to friendly parsed json -


so have web scraping coming this:

["sevent({\"event_id\":\"id\",\"date\":\"sat  5 nov 2016, 19:30\",\"suppress_b... 

now im wanting render in parsed json. how render looks @ moment:

 respond_to |format|        format.json  { render :json => {:testing => price1}}      end 

however returns this:

{   "testing": [     "tmevent({\"event_id\":\"id\",\"date\":\"sat  5 nov 2016, 19:30\ 

how make looks better, (more this):

sevent:{ event_id: id, date: sat  5 nov 2016, 19:30} 

(if place code jsonformatter works , looks how wanted it!)

any help? sam

use pretty_generate function

example:

require 'json' my_object = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } puts json.pretty_generate(my_object)


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -