JSON for List of int

前端 未结 2 1346
一个人的身影
一个人的身影 2020-12-13 23:59

I have a class

public class ItemList
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
             


        
相关标签:
2条回答
  • 2020-12-14 00:32

    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/

    0 讨论(0)
  • 2020-12-14 00:36

    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]
    }
    
    0 讨论(0)
提交回复
热议问题