且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JSON.Net写属性名称

更新时间:2023-01-17 21:16:14

请根对象,然后写属性名称DATA,然后写入对象你只是写道:

Make the root object, then write the property name "DATA", then write the object you just wrote:

jsonWriter.WriteStartObject();
    jsonWriter.WritePropertyName("DATA");
    jsonWriter.WriteStartObject();
        jsonWriter.WritePropertyName("id");
        jsonWriter.WriteValue("234");
        jsonWriter.WritePropertyName("name");
        jsonWriter.WriteValue("abc");
    jsonWriter.WriteEndObject();
jsonWriter.WriteEndObject();