1

我正在查询一个传回 JSON 数据的外部服务。我想将此数据格式化为二进制 PList 以将其发送给客户端。如何在 Rails 中进行转换?这是一个复杂的数据结构,包含数组和哈希以及字符串和整数。

根据评论,我正在尝试这个:

def friends_facebook
  @graph = Koala::Facebook::GraphAPI.new(current_user.facebook_token.token)
  render :plist => JSON.parse(@graph.get_connections("me", "friends").to_json)
end

导致错误(在渲染线上):

incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
4

1 回答 1

0

使用http://plist.rubyforge.org/http://flori.github.com/json/

JSON.parse(input).to_plist

to_plist_node您可能必须为您的数据结构编写自己的方法。

于 2012-05-30T22:13:00.720 回答