【问题标题】:How to read PHP generated json in ruby 1.8.7如何在 ruby​​ 1.8.7 中读取 PHP 生成的 json
【发布时间】:2017-01-23 04:55:53
【问题描述】:

我有一个由 php 应用程序生成的 JSON 哈希值,我想在我的 rails 控制器中读取它。 有什么办法可以再次将这个json转换成哈希值,这样我就可以读取它了。

json_from_php = "{'coms':[{'com':{'title':'kk dd','guid':'http:\/\/tes.name\/?p=02'}},{'com':{'title':'sdsdsdsd dsds','guid':'http:\/\/tes.name\/?p=06'}},{'com':{'title':'PHPTVDB: Using PHP ','guid':'http:\/\/tes.name\/?p=4'}},{'com':{'title':'Plugins','guid':'http:\/\/tes.name\/?p=08'}},{'com':{'title':'vvv','guid':'http:\/\/tes.name\/?p=2218'}},{'com':{'title':'dsds sdsds ','guid':'http:\/\/tes.name\/?p=12'}},{'com':{'title':'Represent ','guid':'http:\/\/tes.name\/?p=5'}},{'com':{'title':'ZebraTable','guid':'http:\/\/tes.name\/?page_id=4'}},{'com':{'title':'rr Plugin','guid':'http:\/\/tes.name\/?p=2'}},{'com':{'title':'dasd asdasd !','guid':'http:\/\/tes.name\/?p=1'}}]}"

#ss = JSON.parser(json_from_php)

错误信息: JSON::ParserError (757: '{'coms':[{'com':{

处的意外标记

参考https://davidwalsh.name/web-service-php-mysql-xml-json

【问题讨论】:

    标签: json hash ruby-1.8.7


    【解决方案1】:
    ss = ActiveSupport::JSON.decode(json_from_php) solved this issue
    

    【讨论】:

      猜你喜欢
      • 2017-01-08
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      • 2011-01-25
      • 2013-02-15
      • 1970-01-01
      • 2018-01-21
      相关资源
      最近更新 更多