I am passing an array from view to the controller using json.stringify() method.
That value is passed to the controller and is in
"\"[{\\\"id\\\":1 "id\\\":2}]\"" format. I think this is in json format, I want to convert this into {id:1,id:2} format.
I tried to convert this into string format using JsonConvert.SerializeObject(),
but it is displaying in "\"\\\"[{\\\\\\\"id\\\\\\\":1}]\\\"\"" format.
Can you tell me how can I convert into {id:1,id:2} format/integer format?
The JSON data represents an array containing a dictionary as far as I can tell. You could get hold of a Dictionary representation of the data like this:
I’m not sure if this is what you’re after though, since you’re saying that you want to display it like
{id: 2}. If you want to print it out like that, you can build a string representation of the Dictionary:This prints
{id: 2}.To retrieve the value for ‘id’, if this is what you mean, you can do this: