[json] JSON for List of int

I have a class

public class ItemList
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public List<int> ItemModList { get; set; }
}

how should i give the input JSON for list of int as it does not have a key to match its value

JSON

{
    "Id": "610",
    "Name": "15",
    "Description": "1.99",
    "ItemModList": []
}

what should I write in the ItemModList

This question is related to json

The answer is


Assuming your ints are 0, 375, 668,5 and 6:

{
    "Id": "610",
    "Name": "15",
    "Description": "1.99",
    "ItemModList": [
                       0,
                       375,
                       668,
                       5,
                       6
                   ]
}

I suggest that you change "Id": "610" to "Id": 610 since it is a integer/long and not a string. You can read more about the JSON format and examples here http://json.org/


JSON is perfectly capable of expressing lists of integers, and the JSON you have posted is valid. You can simply separate the integers by commas:

{
    "Id": "610",
    "Name": "15",
    "Description": "1.99",
    "ItemModList": [42, 47, 139]
}