Ruby解码\ n \ r在JSON中

时间:2015-01-31 22:41:25

标签: ruby json

我有一个JSON数组,它作为文本存储在我的数据库中。当我输出数组时,我仍然看到\ n \ r \ n(见下文)。

我尝试了很多解码方法,但我无法让它工作。有谁知道我如何正确解码这个,以便\ n \ r出现实际的换行符?谢谢!

输出内容:

{\n  \"status\" : 200,\n  \"requestId\" : \"6e2f55da-6a78-4f23-ad79-6be56d51702b\",\n  \"likelihood\" : 0.89,\n  \"photos\" : [ {\n    \"typeId\" : \"gravatar\",\n    \"typeName\" : \"Gravatar\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/76fa9f05dce661f3dfbff6c2ea680cd7_c3360fe21ad70bde88addb0517369e17b6de0d94b85268e20688deda96d6b0a9\",\n    \"isPrimary\" : true\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/c1c2dfa135fa60399c4c1e3e1b8f7ace_9964024ac3eb12645ba7a4bec7aee722ad7735eb413b21a2b9bb008159aeda36\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/c4ac87f9534294c601e7e19a5beb7e99_7d8dbffd5197a74ddc52c0e0f38ef2115f3a451a29b772acdcea6675712d51d7\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/b344190de36a4d1f28fedd46fa897c79_66fbf408e05fa9fac8358b21289c67501286202f096921fdba5a6c7e24241cc5\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/1cd3d316d61527921b82342a9d625c81_30fcfacd7a3d47c704083b4c096d15a44067ec1ff728f977e2c0b110dad1212c\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/c8cb41740384b4ae0e13327c7c576113_7cd8b2d82ae7dce2e1a363743fdc9143df6e031d5827a620051553f9f0937ed2\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/74d39cab61dfe1806e9e7990378798f1_fa637c886a20684d69304c410faf24b3c1c35a7b53d0c3d02b841ec6e6440c73\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"other\",\n    \"typeName\" : \"Other\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/2b674949ec8c368a49aa470a9d8a6b13_bea67ddf0f47b914036602cd2b5152fc356206ab9cd6e1e4787729d4a20a25b7\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/b11e1449e9fbdfd60659ec99fd5299ee_5cef2910cafcdf7e9ce18463f5cae726be0c07205679f60d2effe156bc95e50d\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/cf9e151530e386f6d86450206fd1345a_ea1f4c9ffb6856596b3df04b6b797de722f79a9781ba29bf172c52136f576557\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/164e8187a097530fb3ceb3cd204a5b6c_00a514f697e64eabe87c38cbb95026830acba675117cbff42a15aee559cee7bf\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"pinterest\",\n    \"typeName\" : \"Pinterest\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/7a99570dbf60ab050951f298c465a60c_422594e8f4b814c4189bb4fcc242967182ee12b1d158b37d1fd3808885df30ed\",\n    \"isPrimary\" : false\n  }, {\n    \"typeId\" : \"userclaim\",\n    \"typeName\" : \"userClaim\",\n    \"url\" : \"https://d2ojpxxtu63wzl.cloudfront.net/static/ff0dedb3822efaca0cd530bdecd0a40f_66ee14903c5f7279f8fb2d31cd2e2bb3939291c0f38739972abb57049124fa5d\",\n    \"isPrimary\" : false\n  } ],\n  \"contactInfo\" : {\n    \"chats\" : [ {\n      \"client\" : \"gtalk\",\n      \"handle\" : \"lorangb@gmail.com\"\n    }, {\n      \"client\" : \"skype\",\n      \"handle\" : \"bart.lorang\"\n    }, {\n      \"client\" : \"gtalk\",\n      \"handle\" : \"lorangb@gmail.com\"\n    }, {\n      \"client\" : \"skype\",\n      \"handle\" : \"bart.lorang\"\n    } ],\n    \"websites\" : [ {\n      \"url\" : \"http://fullcontact.com\"\n    }, {\n      \"url\" : \"http://rainmaker.cc\"\n    }, {\n      \"url\" : \"http://fullcontact.com/blog\"\n    }, {\n      \"url\" : \"https://clarity.fm/bartlorang\"\n    }, {\n      \"url\" : \"http://vizify.com/bartlorang\"\n    }, {\n      \"url\" : \"https://cobook.co/bart.lorang\"\n    } ],\n    \"familyName\" : \"Lorang\",\n    \"fullName\" : \"Bart Lorang\",\n    \"givenName\" : \"Bart\"\n  },\n  \"organizations\" : [ {\n    \"isPrimary\" : true,\n    \"name\" : \"FullContact\",\n    \"startDate\" : \"2010-01\",\n    \"title\" : \"Co-Founder & CEO\",\n    \"current\" : true\n  }, {\n    \"isPrimary\" : false,\n    \"name\" : \"Dimension Technology Solutions\",\n    \"startDate\" : \"2009-06\",\n    \"endDate\" : \"2009-12\",\n    \"title\" : \"Owner\",\n    \"current\" : false\n  }, {\n    \"isPrimary\" : false,\n    \"name\" : \"Dimension Technology Solutions\",\n    \"startDate\" : \"2002-06\",\n    \"endDate\" : \"2006-06\",\n    \"title\" : \"Chief Technology Officer\",\n    \"current\" : false\n  }, {\n    \"isPrimary\" : false,\n    \"name\" : \"Dimension Technology Solutions\",\n    \"startDate\" : \"1996-06\",\n    \"endDate\" : \"2002-06\",\n    \"title\" : \"Partner / Development Manager\",\n    \"current\" : false\n  }, {\n    \"isPrimary\" : false,\n    \"name\" : \"Dimension Technology Solutions\",\n    \"startDate\" : \"2006-06\",\n    \"endDate\" : \"2009-06\",\n    \"title\" : \"President\",\n    \"current\" : false\n  } ],\n  \"demographics\" : {\n    \"locationDeduced\" : {\n      \"normalizedLocation\" : \"Boulder, Colorado\",\n      \"deducedLocation\" : \"Boulder, Colorado, United States\",\n      \"city\" : {\n        \"deduced\" : false,\n        \"name\" : \"Boulder\"\n      },\n      \"state\" : {\n        \"deduced\" : false,\n        \"name\" : \"Colorado\",\n        \"code\" : \"CO\"\n      },\n      \"country\" : {\n        \"deduced\" : true,\n        \"name\" : \"United States\",\n        \"code\" : \"US\"\n      },\n      \"continent\" : {\n        \"deduced\" : true,\n        \"name\" : \"North America\"\n      },\n      \"county\" : {\n        \"deduced\" : true,\n        \"name\" : \"Boulder\",\n        \"code\" : \"Boulder\"\n      },\n      \"likelihood\" : 1.0\n    },\n    \"gender\" : \"Male\",\n    \"locationGeneral\" : \"Boulder, Colorado\"\n  },\n  \"socialProfiles\" : [ {\n    \"typeId\" : \"googleplus\",\n    \"typeName\" : \"Google Plus\",\n    \"url\" : \"https://plus.google.com/114426306375480734745\",\n    \"id\" : \"114426306375480734745\"\n  }, {\n    \"typeId\" : \"googleprofile\",\n    \"typeName\" : \"Google Profile\",\n    \"url\" : \"http://profiles.google.com/114426306375480734745\",\n    \"id\" : \"114426306375480734745\"\n  }, {\n    \"typeId\" : \"foursquare\",\n    \"typeName\" : \"Foursquare\",\n    \"url\" : \"http://foursquare.com/10245647\",\n    \"id\" : \"10245647\"\n  }, {\n    \"typeId\" : \"flickr\",\n    \"typeName\" : \"Flickr\",\n    \"url\" : \"http://flickr.com/people/39267654@N00\",\n    \"id\" : \"39267654@N00\"\n  }, {\n    \"typeId\" : \"picasa\",\n    \"typeName\" : \"Picasa\",\n    \"url\" : \"http://picasaweb.google.com/lorangb\",\n    \"username\" : \"lorangb\"\n  }, {\n    \"type\" : \"klout\",\n    \"typeId\" : \"klout\",\n    \"typeName\" : \"Klout\",\n    \"url\" : \"http://klout.com/bartlorang\",\n    \"username\" : \"bartlorang\",\n    \"id\" : \"35747326808831033\"\n  }, {\n    \"bio\" : \"CEO & Co-Founder of @FullContactApp - Tech Entrepreneur, Angel Investor. New father and writing about it here: https://t.co/QhPGyQjBqr\",\n    \"followers\" : 4507,\n    \"following\" : 694,\n    \"type\" : \"twitter\",\n    \"typeId\" : \"twitter\",\n    \"typeName\" : \"Twitter\",\n    \"url\" : \"https://twitter.com/bartlorang\",\n    \"username\" : \"bartlorang\",\n    \"id\" : \"5998422\"\n  }, {\n    \"type\" : \"github\",\n    \"typeId\" : \"github\",\n    \"typeName\" : \"Github\",\n    \"url\" : \"https://github.com/lorangb\",\n    \"username\" : \"lorangb\"\n  }, {\n    \"type\" : \"facebook\",\n    \"typeId\" : \"facebook\",\n    \"typeName\" : \"Facebook\",\n    \"url\" : \"https://www.facebook.com/bart.lorang\",\n    \"username\" : \"bart.lorang\",\n    \"id\" : \"651620441\"\n  }, {\n    \"bio\" : \"Co-Founder and CEO of FullContact\",\n    \"type\" : \"aboutme\",\n    \"typeId\" : \"aboutme\",\n    \"typeName\" : \"About.me\",\n    \"url\" : \"https://about.me/lorangb\",\n    \"username\" : \"lorangb\"\n  }, {\n    \"bio\" : \"Entrepeneur, Tech Nerd; CEO and Co-Founder of @fullcontact. Passionate about solving the world's contact information problem and helping entrepreneurs.\",\n    \"followers\" : 2399,\n    \"following\" : 0,\n    \"type\" : \"angellist\",\n    \"typeId\" : \"angellist\",\n    \"typeName\" : \"AngelList\",\n    \"url\" : \"https://angel.co/bartlorang\",\n    \"username\" : \"bartlorang\",\n    \"id\" : \"182\"\n  }, {\n    \"type\" : \"youtube\",\n    \"typeId\" : \"youtube\",\n    \"typeName\" : \"YouTube\",\n    \"url\" : \"https://youtube.com/user/lorangb\",\n    \"username\" : \"lorangb\"\n  }, {\n    \"type\" : \"quora\",\n    \"typeId\" : \"quora\",\n    \"typeName\" : \"Quora\",\n    \"url\" : \"http://www.quora.com/Bart-Lorang\",\n    \"username\" : \"Bart-Lorang\"\n  }, {\n    \"type\" : \"pinterest\",\n    \"typeId\" : \"pinterest\",\n    \"typeName\" : \"Pinterest\",\n    \"url\" : \"http://www.pinterest.com/lorangb/\",\n    \"username\" : \"lorangb\"\n  }, {\n    \"bio\" : \"Co-Founder & CEO at FullContact\",\n    \"type\" : \"linkedin\",\n    \"typeId\" : \"linkedin\",\n    \"typeName\" : \"LinkedIn\",\n    \"url\" : \"https://www.linkedin.com/in/bartlorang\",\n    \"username\" : \"bartlorang\"\n  }, {\n    \"bio\" : \"http://about.me/lorangb\",\n    \"type\" : \"gravatar\",\n    \"typeId\" : \"gravatar\",\n    \"typeName\" : \"Gravatar\",\n    \"url\" : \"https://gravatar.com/blorang\",\n    \"username\" : \"blorang\",\n    \"id\" : \"18197740\"\n  } ],\n  \"digitalFootprint\" : {\n    \"scores\" : [ {\n      \"provider\" : \"klout\",\n      \"type\" : \"general\",\n      \"value\" : 52\n    } ],\n    \"topics\" : [ {\n      \"provider\" : \"klout\",\n      \"value\" : \"Denver\"\n    }, {\n      \"provider\" : \"klout\",\n      \"value\" : \"Software\"\n    }, {\n      \"provider\" : \"klout\",\n      \"value\" : \"Boulder\"\n    }, {\n      \"provider\" : \"aboutme\",\n      \"value\" : \"Angel Investor\"\n    }, {\n      \"provider\" : \"aboutme\",\n      \"value\" : \"Tech Nerd\"\n    }, {\n      \"provider\" : \"klout\",\n      \"value\" : \"APIs\"\n    }, {\n      \"provider\" : \"klout\",\n      \"value\" : \"Entrepreneurship\"\n    }, {\n      \"provider\" : \"aboutme\",\n      \"value\" : \"Husband\"\n    }, {\n      \"provider\" : \"aboutme\",\n      \"value\" : \"Entrepreneur\"\n    } ]\n  }\n}","created_at":"2015-01-31T22:36:47.284Z","updated_at":"2015-01-31T22:36:47.284Z"}

我想看到的内容:

{
  "status" : 200,
  "requestId" : "85366a2e-2c63-4358-9081-d0c6ee91356c",
  "likelihood" : 0.89,
  "photos" : [ {
    "typeId" : "gravatar",
    "typeName" : "Gravatar",
    "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/76fa9f05dce661f3dfbff6c2ea680cd7_c3360fe21ad70bde88addb0517369e17b6de0d94b85268e20688deda96d6b0a9",
    "isPrimary" : true
  }, {
    "typeId" : "userclaim",
    "typeName" : "userClaim",
    "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/c1c2dfa135fa60399c4c1e3e1b8f7ace_9964024ac3eb12645ba7a4bec7aee722ad7735eb413b21a2b9bb008159aeda36",
    "isPrimary" : false
  }, {

0 个答案:

没有答案