JSON or XML or serialized array for storing in MySQL database

Web application. Get data from services in json and xml formats . And from the internal module to the hash.

It was decided to choose one format for all saved data.

more details:

  • Read more than write.

  • Low nested data (<10).

  • Char is counted between 1000 - 100000.

  • The programming language is ruby.

  • Frame rails.

  • DB mysql.

What is your recommendation?

+3
source share
3 answers

Ruby . Blob. . JSON , /-. XML, /

+1

JSON MySQL , . XML , , JavaScript, JSON , .

ActiveModel Rails 3. , , ActiveRecord, . JSON/XML, , , .

+1

JSON XML

API, ActiveModel .

JSON YAJL-ruby - : http://rdoc.info/projects/brianmario/yajl-ruby

Activerecord , .. , attr:

. " , " : http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001799

:

class User < ActiveRecord::Base
  serialize :preferences
end

user = User.create(:preferences => { "background" => "black", "display" => large })
User.find(user.id).preferences # => { "background" => "black", "display" => large }
0

Source: https://habr.com/ru/post/1756556/


All Articles