Abu*_*man 3 java json scala apache-spark
我在JAVA中解析SparkSQL中的json文件,我需要能够访问在WrappedArrays的WrappedArray中返回的坐标.这是代码:
df.registerTempTable("test_articles");
sql = "select gnip.profileLocations.geo.coordinates FROM test_articles";
DataFrame testData = sqlContext.sql(sql);
Row [] rowArray = testData.collect();
for(Row r:rowArray)
{
if(r.get(0)!=null)
System.out.println(r.get(0).toString());
}
Run Code Online (Sandbox Code Playgroud)
OUTPUT:WrappedArray(WrappedArray(30.74806,40.79944))
file.json
"gnip": {
"profileLocations": [{
"objectType": "place",
"geo": {
"type": "point",
"coordinates": [132.56111,
35.07693]
}
}]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6737 次 |
| 最近记录: |