0

我正在尝试从源表中查询数据,但无法正确查看结果。

源表结构

c1 string,
c2 string,
c3 string,
temp1 struct
<
s1 : string,
s2 : string,
s3 : string,
temp2 : array<struct<as1 string,as2 :string>>                 
>

我有JSON格式的数据。

我的 JSON 数据采用以下格式

{"c1":"123","c2":"XYZ","c3":"IIK",
"temp1":{"s1":"low","s2":"45","s3":"yes"},
"temp2":[{"as1":"16-05-1992","as2":"fail"}]
}

根据我的表结构,我应该在结构中包含数组(结构)。但我所拥有的数据并非如此。我分别有 struct 和 array(struct) 。现在,当我查询此表时,我按预期获得了列 c1、c2、c3、s1、s2 的所有记录,但我没有得到 as1 和 as2 列,而是在输出中将temp2本身设为null。我在这里有什么遗漏吗。我应该有类似的数据struct<array<struct>>还是可以拆分struct并且array<struct>json serde在阅读时会小心

4

1 回答 1

0

根据您的数据示例,它应该是struct并且array<struct>

c1 string,
c2 string,
c3 string,
temp1 struct
<
s1 : string,
s2 : string,
s3 : string
>,
temp2 : array<struct<as1 string,as2 :string>> 

单个 JSON 对象应在一行中,不支持多行 json:

{"c1":"123","c2":"XYZ","c3":"IIK","temp1":"s1":"low","s2":"45","s3":"yes"},"temp2":[{"as1":"16-05-1992","as2":"fail"}]}
于 2018-06-24T16:27:27.607 回答