I want to render a simple JSON from an array.
array = ["valueid",true]
render :json=>array
which returns:
{"json":["valueid",true]}
but I don't want the JSON. The only part I want is:
["valueid",true]
Is there a simple way?
Yep:
get :index do
[:id, 4].to_json
end
Better:
get :index, :provides => :json do
my_array.to_json
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.