I have a list of strings in C# List and need to return a json structure that looks like this:
'String1': { name: 'String1' }
What is the best and easiest way to achieve this?
Edit: I do not need a serializer, I strictly need help with the structure. I am using .net mvc JsonResult.
To be valid JSON it should look like this:
If you know that the strings doesn’t contain anything that needs encoding (e.g. quotation marks), which is likely if you want to use them as identifiers, you can just do the serialisation yourself:
where
listis your list of strings.