-1

I will upload products with API.

The json data that needs to go should be as follows;

"cross": [ { "dynamicName_X" : "123000" }, { "dynamicName_Y" : "456000" }]

I'm doing it with keyvaluepair. It becomes the following with JsonConvert.SerializeObject.

"cross": [ { "Key": "dynamicName_X", "Value": "123000" }, { "Key": "dynamicName_Y", "Value": "456000" } ]

What can I do. What can I do to get it like below when I convert it with JsonConvert.SerializeObject. The cross value must be a list with dynamic parameter names.

"cross": [ { "dynamicName_X" : "123000" }, { "dynamicName_Y" : "456000" }, ]
dbc
  • 91,441
  • 18
  • 186
  • 284
  • Have you tried using an anonymous object instead? – maccettura May 16 '22 at 16:16
  • Easiest way is to deserialize `cross` to a `List>`. Otherwise you will need to write a custom converter. See [Deserialize array of key value pairs using Json.NET](https://stackoverflow.com/q/15789539) which looks to be a duplicate. – dbc May 28 '22 at 19:48

0 Answers0