我想使用R tidyjson包的开发者版本从JSON对象中拉选择数组。我想从下面的示例JSON对象创建下面的示例表。任何帮助,将不胜感激。使用tidyjson从JSON中拉数组
下面是表我试图创建:
document.id location.lat location.lng viewport name place_id
1 32.123451 -85.234541 northeast Name1 sdfdfasdfasdfdasfdas
1 32.123451 -85.234541 southwest Name1 sdfdfasdfasdfdasfdas
2 33.345454 -84.345454 northeast Name2 sdfdsfdsfdff
2 33.345454 -84.345454 southwest Name2 sdfdsfdsfdff
这里是我的JSON对象:
JSON_TEST <- "{
\"html_attributions\" : [],
\"results\" : [
{
\"geometry\" : {
\"location\" : {
\"lat\" : 32.123451,
\"lng\" : -85.234541
},
\"viewport\" : {
\"northeast\" : {
\"lat\" : 32.234341,
\"lng\" : -85.345655
},
\"southwest\" : {
\"lat\" : 32.235624,
\"lng\" : -85.234655
}
}
},
\"icon\" : \"https://fake/fake/fake1.png\",
\"id\" : \"qwerqewrqwerqewrqewrqwreqewrqewrqwr\",
\"name\" : \"Name1\",
\"place_id\" : \"sdfdfasdfasdfdasfdas\",
\"reference\" : \"asdfdasfadsfdasfdfdfdffff\",
\"scope\" : \"TEST1\",
\"types\" : [
\"bar\",
\"liquor_store\",
\"food\",
\"store\",
\"point_of_interest\",
\"establishment\"
],
\"vicinity\" : \"343 Fake Place Lane, Atlanta\"
},
{
\"geometry\" : {
\"location\" : {
\"lat\" : 33.345454,
\"lng\" : -84.345454
},
\"viewport\" : {
\"northeast\" : {
\"lat\" : 33.234534
\"lng\" : -84.234643
},
\"southwest\" : {
\"lat\" : 33.345443,
\"lng\" : -84.345422
}
}
},
\"icon\" : \"https://fake/fake/fake2.png\",
\"id\" : \"sdfdsfdsfdff\",
\"name\" : \"Name2\",
\"place_id\" : \"sadfsdfdfdf\",
\"reference\" : \"asdfdasfdsfd\",
\"scope\" : \"TEST2\",
\"types\" : [ \"bar\", \"point_of_interest\", \"establishment\" ],
\"vicinity\" : \"21434 Fake Place Ave, Atlanta\"
}
],
\"status\" : \"OK\"
}
"
你错过一对夫妇逃逸和一个逗号。 – alistaire
感谢alistaire,我只是编辑了JSON对象并相信我已经修复了转义和逗号。 – Bdude11383
根据您的[其他问题](https://stackoverflow.com/q/45242400/5977215),您可以使用我的'googleway'包直接查询Google Places API – SymbolixAU