压缩JSON字符串

时间:2012-12-11 08:45:20

标签: ruby-on-rails ruby json

我有一个帖子请求返回的这个JSON字符串,我在rails上的ruby:

{"a":[{"id":2816,"tr":990,"lub":"mattia1.lipreri","p":"0.20","b":"0"},{"id":2817,"tr":992,"lub":"mattia1.lipreri","p":"0.20","b":"0"},{"id":2818,"tr":993,"lub":"mattia1.lipreri","p":"0.20","b":"0"},{"id":2819,"tr":994,"lub":"mattia1.lipreri","p":"0.20","b":"0"},{"id":2820,"tr":995,"lub":"mattia1.lipreri","p":"0.20","b":"0"}]}

我想知道是否有办法压缩它,也许用hpack或cjson,任何提示? 谢谢

2 个答案:

答案 0 :(得分:1)

看一下bson gem:http://rubygems.org/gems/bson。它在内部用于mongodb驱动程序。

答案 1 :(得分:1)