Comment obtenir la sous-chaîne d'une sortie JSON?
-
29-10-2019 - |
Question
Je veux rendre un simple JSON à partir d'un tableau.
array = ["valueid",true]
render :json=>array
qui revient:
{"json":["valueid",true]}
Mais je ne veux pas du JSON. La seule partie que je veux est:
["valueid",true]
Y a-t-il un moyen simple?
La solution
Ouais:
get :index do
[:id, 4].to_json
end
Meilleur:
get :index, :provides => :json do
my_array.to_json
end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow