Convert json file to R object in R -
Convert json file to R object in R -
i trying convert json file in r. format of info follows:
{ "id": "xyz", "root": { "author": { "name": "xyz", "email": "xyx@xyz.org", "date": "2014-10-08t00:10:30z" }, "authorer": { "name": "xyz", "email": "xyx@xyz.org", "date": "2014-10-08t00:11:30z"  }, "message": "this test json", "root": { "id": "xyz1", "url": "xyz" }, "url": "xyz", "message_count": 0 }, "url": "xyz", "html_url": "xyz", "comments_url": "abc", "author": null, "authorer": null, "parent": [ { "id": "xyz3", "url": "xyz", "html_url": "xyz" } ] }    after similar row begins, {having same formatted text }this code wrote in r
install.packages("rjson") library(rjson) df <- fromjson(paste(readlines("file.json"), collapse="")) view(df)    i wondering how create file readable in r? wanted see them columns this:
id  root/author/name    root/author/email   root/author/date    root/authorer/name      refer here: http://konklone.io/json/?id=dfeae96a607c7541b8fe (of how input , output should like).
i have provided new link here 2 rows: http://konklone.io/json/?id=3b01a02e17ec4fde3357
thanks lot
is want:
json <- '{   "id": "xyz",   "root": {     "author": {       "name": "xyz",       "email": "xyx@xyz.org",       "date": "2014-10-08t00:10:30z"     },     "authorer": {       "name": "xyz",       "email": "xyx@xyz.org",       "date": "2014-10-08t00:11:30z"     },     "message": "this test json",     "root": {       "id": "xyz1",       "url": "xyz"     },     "url": "xyz",     "message_count": 0   },   "url": "xyz",   "html_url": "xyz",   "comments_url": "abc",   "author": null,   "authorer": null,   "parent": [     {       "id": "xyz3",       "url": "xyz",       "html_url": "xyz"     }   ] }'  out <- jsonlite::fromjson(json) out[vapply(out, is.null, logical(1))] <- "none" data.frame(out, stringsasfactors = false)[,1:5]     id root.author.name root.author.email     root.author.date root.authorer.name 1 xyz              xyz       xyx@xyz.org 2014-10-08t00:10:30z                xyz        json r rjson 
 
  
Comments
Post a Comment