簡體   English   中英

如何在Rails中將JSON數據轉換為PList數據?

[英]How can I convert JSON data to PList data in Rails?

我正在查詢傳回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)

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

JSON.parse(input).to_plist

您可能必須為數據結構編寫自己的to_plist_node方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM