我有一个在线的 JSON 文件。
{
"icao": "f3b100",
"noRegData": true,
"timestamp": 1690848000,
"trace": [
[
51213.77,
39.090519,
-85.870361,
4500,
95,
359.4,
5,
0,
{
"type": "tisb_icao",
"track": 359.4,
"geom_rate": 0,
"nic": 0,
"rc": 0,
"nac_p": 0,
"nac_v": 0,
"sil": 0,
"sil_type": "unknown",
"alert": 0,
"spi": 0
},
"tisb_icao",
null,
0,
null,
null,
"f9adebf3"
]
]
}
我将此 JSON 文件上传到 S3 并尝试使用 AWS Glue 读取它。
但是,在 AWS Glue 中,它读取/解析为
注意
trace
字段变为
[
[
{
"double": 51213.77,
"int": null,
"string": null,
"struct": null
},
{
"double": 39.090519,
"int": null,
"string": null,
"struct": null
},
{
"double": -85.870361,
"int": null,
"string": null,
"struct": null
},
{
"double": null,
"int": 4500,
"string": null,
"struct": null
},
{
"double": 95,
"int": null,
"string": null,
"struct": null
},
{
"double": 359.4,
"int": null,
"string": null,
"struct": null
},
{
"double": null,
"int": 5,
"string": null,
"struct": null
},
{
"double": null,
"int": 0,
"string": null,
"struct": null
},
{
"double": null,
"int": null,
"string": null,
"struct": {
"type": "tisb_icao",
"alt_geom": null,
"track": 359.4,
"geom_rate": 0,
"nic": 0,
"rc": 0,
"nac_p": 0,
"nac_v": 0,
"sil": 0,
"sil_type": "unknown",
"alert": 0,
"spi": 0
}
},
{
"double": null,
"int": null,
"string": "tisb_icao",
"struct": null
},
{
"double": null,
"int": null,
"string": null,
"struct": null
},
{
"double": null,
"int": 0,
"string": null,
"struct": null
},
{
"double": null,
"int": null,
"string": null,
"struct": null
},
{
"double": null,
"int": null,
"string": null,
"struct": null
},
{
"double": null,
"int": null,
"string": "f9adebf3",
"struct": null
}
]
]
在另一个页面中我看到
trace
有这个模式
array<array<struct<double:double,int:int,string:string,struct:struct<type:string,track:double,geom_rate:int,nic:int,rc:int,nac_p:int,nac_v:int,sil:int,sil_type:string,alert:int,spi:int>>>>
与新版本的
trace
字段匹配。
trace
中的原始数据格式消失了。这是预期的行为吗?
有人可以指导我如何正确读取原始
trace
数组吗?谢谢!
我相信我理解这种“double/int/string/struct”格式的起源。
因为
trace
是数组的数组。在第二级数组中,默认情况下,如果所有值都是同一类型,例如string
,则为array<string>
。
但是,在这个特定场景中,第二级数组是包括
double
、int
、string
和 struct
在内的元素的混合。
因此,AWS Glue 尝试解析这种混合物,导致“double/int/string/struct”格式的出现。
在我看来,我有两种可能的方法:要么在 AWS Glue 本身内处理这种新格式的数据,要么在使用 AWS Glue 之前进行一些预处理。