我想将JSON文件转换为R中的data.table [英] I want to convert JSON file into data.table in r

查看:130
本文介绍了我想将JSON文件转换为R中的data.table的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将json文件转换为r中的data.table时遇到了一个问题, 我已经使用了RJSONIO包中的fromJSON函数,但没有得到所需的输出.

I have been facing a problem to convert json file into data.table in r, I have using the fromJSON function from the RJSONIO package but I am not getting the desired output.

Here is the link from which I got the JSON object using getURL.

JSON对象在下面给出.

JSON object is given below.

{
   "html_attributions" : [],
   "next_page_token" : "CoQC_AAAAD5d9OlUyry65wwf069o_yY_yuPswsNO0_09Q3dne0_Zyu3ubeRm6pY0IAz7TScgjuHQBc0XW-LPz5dIXK9dAvYf_6yrcUW0ifZ33QzO3YNl7lFcKxQTZje9eJp9E_ahoE5JPVEfnhiqZYV74WQikxJoD44FM7DlFqHDE5G8lTiTsfIhRIJo769JjGSjyhtC3UtTSzz9CVLzaiyk2PEBlq1ARk5xdnW0dEaKEed5FaGg1EkGDickRFf1jxM0DuKicfgy03iaobdJ77Wce6PhsH4OrEOnhPpF5MjgAXOTyAKFg5Su63BhB3vsqjzu_c-JBmz9P2YltIU9yqayl0_LkjkSEMBmNgKELkPWAa1ykqBkAE8aFJ7yB_bLCvDJg8XUpE80oEt_ZB7l",
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : 18.93224529999999,
               "lng" : 72.82643779999999
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 18.9446469,
                  "lng" : 72.830484
               },
               "southwest" : {
                  "lat" : 18.926386,
                  "lng" : 72.821804
               }
            }
         },

我想在Google地图附近找到一个垂直地址之一.

I want to find out near by from google map for one of the perticular address.

所以,请帮助我完成此任务,即将json文件转换为data.table

So, please help me to complete this task i.e to convert json file into data.table

推荐答案

如@jangorecki所述,您可以使用jsonlite包中的fromJSON()函数将JSON对象转换为数据帧.从那里,将data.frame转换为data.table应该很简单.

As @jangorecki mentioned, you can use the fromJSON() function from the jsonlitepackage to turn a JSON object into a dataframe. From there, it should be straightforward to convert the data.frame to a data.table.

这篇关于我想将JSON文件转换为R中的data.table的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆