jbest
jbest

Reputation: 640

Print json response from API in R

I have been using httr library in R and the function GET. I encoded this line:

GET(url,add_headers("user" = "password"))

And this is the response:

Response [url]
  Date: 2015-10-28 08:38
  Status: 200
  Content-Type: application/json; charset=UTF-8
  Size: 10.6 kB

I want to know how can I print the json response of this API.

Upvotes: 0

Views: 2093

Answers (1)

jbest
jbest

Reputation: 640

I used function content to turn my result into json as seen below:

data_get<- GET(url,add_headers("user" = "password"))

get2json<- content(data_get, as = "parsed")

parse2json<- (toJSON(get2json))

Upvotes: 1

Related Questions