Unable to Access data from json object

后端 未结 2 1705
感动是毒
感动是毒 2021-01-24 13:29

I have stored json data structure in a dataframe with single column, named json_data in R so my json text is stored in this format

row 1)    { \         


        
2条回答
  •  一整个雨季
    2021-01-24 13:56

    Here is one possibility:

    library(rjson)
    
    json_data <- fromJSON(file = json_file)
    formatted_add <- lapply(json_data$results, function(x) x$formatted_add)
    lat <- lapply(json_data$results, function(x) x$geometry$location$lat)
    lng <- lapply(json_data$results, function(x) x$geometry$location$lng)
    
    data <- cbind(formatted_add, lat, lng)
    

    I hope this is what you need.

提交回复
热议问题