我正在使用 NewtosoftJson 生成 json 字符串,并使用表来格式化 json。这是一个简单的键值对列表,如下所示:
public class items
{
private string key = String.Empty;
private string value = String.Empty;
public string Key
{
get
{
return key;
}
set
{
if (value != key)
{
key = value;
}
}
}
public string Value
{
get
{
return value;
}
set
{
if (value != this.value)
{
this.value = value;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当列表被填充然后序列化时,我得到这个 JSON:
"Items": [
{
"Key":"FirstValue",
"Value":"One"
},
{
"Key":"SecondValue",
"Value":"Two"
},
{
"Key":"ThirdValue",
"Value":"Three" …Run Code Online (Sandbox Code Playgroud)