Reputation: 1
I'm converting Json complex data to CSV file.
This is my code:
StringBuilder csv = new StringBuilder();
using (var r = new ChoJSONReader(FileNameSample33JSON)
.WithJSONPath("$..getUsers[*]", true))
{
using (var w = new ChoCSVWriter(csv)
.WithFirstLineHeader()
.WithMaxScanRows(10)
.Configure(c => c.ThrowAndStopOnMissingField = false))
w.Write(r);
}
JSON:
"extension": [
{
"Test": "value",
"value": [ "0", "1", "2" ]
},
{
"Test1": "Test",
"value": "20"
},
{
"Test2": "Test",
"value": "35"
}
]
The issue is values 20 and 35 are missing because in the first object, the value field is a list, while in the subsequent objects, value is not a list. This inconsistency causes the values to be overlooked.
I want all values like
extension_0_value_0 | extension_0_value_1 | extension_0_value_2 | extension_1_value | extension_2_value |
---|---|---|---|---|
0 | 1 | 2 | 20 | 35 |
How to fix this issue..?
Upvotes: 0
Views: 43