Ruby objects and JSON serialization (without Rails)

前端 未结 11 1967
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 03:32

I\'m trying to understand the JSON serialization landscape in Ruby. I\'m new to Ruby.

Is there any good JSON serialization options if you are not working with Rails?

11条回答
  •  猫巷女王i
    2020-11-28 04:20

    If rendering performance is critical, you might also want to look at yajl-ruby, which is a binding to the C yajl library. The serialization API for that one looks like:

    require 'yajl'
    Yajl::Encoder.encode({"foo" => "bar"}) #=> "{\"foo\":\"bar\"}"
    

提交回复
热议问题