I have a JSON file content like this:
{
"cars": [
{
"code": "MB-GLS",
"name": "Mercedes-Benz GLS 350 d 4MATIC",
"stock": {
"AMG 9G-Tronic 2016 Blue",
"4M AMG 2017 Black"
}
},
{
"code": "BM-420D",
"name": "BMW 420d Cabrio",
"stock": {
"420d Cabrio Luxury Line 2015 White",
"M Sport 420d Cabrio Red 2018",
"420d Cabrio Premium 2014 Black",
"420d Cabrio Premium 2015 White"
}
},
{
"code": "AU-A5",
"name": "A5 Sportback 2.0 TDI quattro",
"stock": {
"2.0 TDI quattro Dynamic 2018 Grey",
"2.0 TDI quattro S-Line 2018 Black",
"2.0 TDI quattro S-Line 2018 Indigo",
"2.0 TDI quattro Design 2017 White",
"2.0 TDI quattro Design 2016 Black"
}
},
{
"code": "TS-MOS",
"name": "Tesla Model S",
"stock": {
"Model S 75D 525 PS 2018 White",
"Model S 75D 525 PS 2018 Indigo",
"Model S 90D 2017 Red",
"Model S P100D 775 PS 2018 Smoke-Colored",
"Model S P100D 775 PS 2018 White",
"Model S P85+ 2013 Blue"
}
}
]
}
I want to create a treeview content from this JSON data on the WinForms. And I want to use treeView1
control for it too. Lastly I am using JSON.Net for create JSON object.
The result I hope is the following: TreeView content with created photoshop for example
I don't any idea, how can I manage this.
EDIT : When I try Creating tree view dynamically according to json text in Winforms subjected example, it gives an error like this: Invalid character after parsing property name. Exprected ':' but got: ,. Path 'cars[0].stock', line 7, position 29.
. It gives, because it wants stock like this:
"stock": {
"1": "420d Cabrio Luxury Line 2015 White",
"2": "M Sport 420d Cabrio Red 2018",
"3": "420d Cabrio Premium 2014 Black",
"4": "420d Cabrio Premium 2015 White"
}
But our stock does not like this.
And finally when I try How to recursively populate a TreeView with JSON data
it gives an error like this: Illegal characters in path', line 7, position 29.
. I checked json data, you also see, there is no error in the JSON data.