用于int列表的JSON [英] JSON for List of int

查看:175
本文介绍了用于int列表的JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上课

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

我应该如何为int列表提供输入JSON,因为它没有匹配其值的键

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": []
}

我应该在ItemModList中写什么

what should I write in the ItemModList

推荐答案

假设您的整数分别为0、375、668,5和6:

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

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

我建议您将"Id":"610"更改为"Id":610,因为它是整数/长整数而不是字符串.您可以在 http://json.org/

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/

这篇关于用于int列表的JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆