How to create a collection, for example List <String, Object>?
I need to create a list like List<String,Object> , but I cannot do this.
I created a class:
public class Pair { public String Key { get; set; } public Object Value { get; set; } } If I create a List<Pair> , my problem starts when I have to serialize it to JSON, I get something like:
{
"Key": "version",
"Value": "3.2.1"
},
{
"Key": "name",
"Value": "coordinateOperations"
}
While I expect:
{
"version": "3.2.1"
},
{
"name": "coordinateOperations"
}
I assume that I need to either find a way to have List<String,Object> , or control the serialization mechanism. The latter looks tougher and seems more like a trick than a real solution.
Also, I cannot have Dictionary<String,Object> , since I will have duplicate keys. Perhaps a search is more necessary.
+4