Czeshirecat Czeshirecat - 2 months ago 10
JSON Question

What is the c# equivalent of "Map<Integer, List<String>> propName;" please?

How do I declare

Map<Integer, List<String>> propName
in my c# web client please so that it will unparse a json string/class that looks like

"propName" : {3: ["userId", "email"]}


I did google this before asking here but didn't find an answer specific to what looks like a complex type that the web api guy sent me below. I don't recognise the
Map<,>
data struct he's using.

public class ErrorObject
{
int error;
string errorText;
string hint;
Map<Integer, List<String>> propName; // e.g. "propName" : {3: ["userId", "email"]}
}

Answer

That should work:

public class ErrorObject
{
    int error;
    String errorText;
    String hint;
    Dictionary<int, List<String>> propName;
}

But you can also simply paste your full JSON to this converter and it will give you the matching class structure in C#.

Comments