首頁  >  問答  >  主體

ruby - How to get data by curb gem better?

I use curb gem to get some data from other website.

When I try

http = Curl.get("http://www.somesite.com/")
puts http.body_str

The data were

"{\"data\":[{\"id\":\"10000123456789\",\"name\":\"\\u1234\\u1234 \\u1234\\u1234\"},{\"id\":\"10000123465789\",\"name\":\"\\u1234\\u1234 \\u1234\\u1234\"},...}}}"

How to get data or id or name?

伊谢尔伦伊谢尔伦2762 天前715

全部回覆(1)我來回復

  • 迷茫

    迷茫2017-04-21 11:19:17

    回傳的是json資料吧,使用ruby的json模組處理

    http://www.ruby-doc.org/stdlib-1.9.3/libdoc/json/rdoc/JSON.html#method-i-parse

    回覆
    0
  • 取消回覆