1

I am not sure how to correctly ask my question.

I'm facing a problem using JSON.net: The point is, I am receiving this JSON from a webservice. Apparently this thing has never heard of object oriented programming, and my JSON has the following exemplary structure:

"meta": {
"collection_t1_driver_selected_invoiceaccount": "911156",
"collection_t1_scandate": "11 mei 2020",
"collection_t1_scandate-value": "2020-05-11",

"collection_t2_driver_selected_invoiceaccount": "911156",
"collection_t2_scandate": "11 mei 2020",
"collection_t2_scandate-value": "2020-05-11",
"collection_t3_driver_selected_invoiceaccount": "911156",
"collection_t3_scandate": "11 mei 2020",
"collection_t3_scandate-value": "2020-05-11"

}

As you can see there are 3 similar blocks. Is there any way to serialize this into a collection of 3 times the same object with 3 fields with JSON.net?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

1 Answers1

0

Wow, 3 days and I post the same answer on each day: C# Convert Json to object with duplicated property name with different data type

Basically you write a specific JsonConvert class that creates a 'union' of all the possible types and then parses the input field and adds the data to one of the union members.

Neil
  • 11,059
  • 3
  • 31
  • 56