According to https://www.ruby-toolbox.com/categories/JSON_Parsers , I should get crazy speedups when serializing hashes using Oj. I installed the last stone, included it in my Gemfile, started the installation of the package and was able to confirm that it is getting used to it. How can _know_, which JSON rendering is active in my Rails 3 application? However, there was no acceleration in the JSON response.
In the library, I query the legacy MySQL database with the Ruby mysql module. I convert strings to values and return an array of hashes. This works great, and it takes 1.5 to 2 seconds. A piece of data should be found here.
CONTROLLER
@data = Gina.points(params[:project], params[:test],
session[:username], session[:password])
respond_to do |format|
format.html { render :text => @data }
format.json { render :json => @data }
end
Library
dbh = Mysql.real_connect(@@host, u, p)
res = dbh.query("SELECT * FROM #{d}.#{t}")
@data = []
res.each_hash do |row|
obj = {}
row.each_pair do |k, v|
v.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? obj[k] = v : obj[k] = v.to_f
end
@data << obj
end
"render: json". 1,5 8 9 . (3,5 - 4 ) 25 30. JSON , "" , .get jQuery , JS . 1,4 5 .
JSON , , . - , , SIX TIMES . , , , "" JSON , "" ( , ). , , , " " JSON .
, Oj , - ?