How to parse and flatten a nested JSON available in a Hive/Hbase column using spark scala?
Example:
A hive table is having a column "c1" with following json
{
"fruit": "Apple",
"size": "Large",
"color": "Red",
"Lines": [{
"LineNumber": 1,
"Text": "ABC"
},
{
"LineNumber": 2,
"Text": "123"
}
]
}
I want to parse this json and create a dataframe to contain columns and values like this
+------+------+-------+------------+------+
|fruit | size | color | LineNumber | Text |
+------+------+-------+------------+------+
|Apple | Large| Red | 1 | ABC |
|Apple | Large| Red | 2 | 123 |
+------+------+-------+------------+------+
Appreciate any thoughts. Thanks!