我有一個嵌套的結構體,在字段是一個字符串,它看起來像這樣....
字符串=
“[{\“to_loc \”, \“6183 \”, \“to_loc_type \”: \“\”, \“qty_allocated \”: \“18 \”}, {\“to_loc \”, \“6137 \”, \“to_loc_type \”: \“\”, \“qty_allocated \”: \“9 \”}, {\“to_loc \”, \“6088 \”, \“to_loc_type \”: \“\”, \“qty_allocated \”: \ " 9 \ "})”
我的目標是讓它變成一個數組的結構體,因此每個結構體在這個字符串可以被爆炸成一個新行。像這樣,
C1, C2, C3
_、_ {“to_loc \”, \“6183 \”, \“to_loc_type \”, \“\”, \“qty_allocated \”, \“18 \}
_、_ {“to_loc \”, \“6137 \”, \“to_loc_type \”, \“\”, \“qty_allocated \”, \“9 \}
_、_ {“to_loc \”, \“6088 \”, \“to_loc_type \”, \“\”, \“qty_allocated \”, \“9 \}
這最後的鑰匙也可以作為一個新列
我試著通過鑄造字符串列的數組結構,但火花拒絕把我的字符串列。任何幫助在這
最後模式=
ArrayType (StructType (
[StructField (“to_loc StringType(),真的),
StructField (“to_loc_type StringType(),真的),
StructField (“qty_allocated StringType(),真的))
))