第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

NewtonSoft Json轉(zhuǎn)換列表

NewtonSoft Json轉(zhuǎn)換列表

C#
溫溫醬 2023-08-13 15:59:07
我有一個(gè)非常簡(jiǎn)單的結(jié)構(gòu),我想使用牛頓軟 Json 序列化來(lái)序列化。定義:public enum SensorType{    Temperature,    Flow,    Pressure}public enum SensorLocation{    Manifold,    TopVessel,    WaferStage}[JsonArray]public class SensorConfiguration{    [JsonProperty]    public string Name { get; set; }    [JsonConverter(typeof(StringEnumConverter))]    public SensorType Type { get; set; }    [JsonConverter(typeof(StringEnumConverter))]    public SensorLocation Location { get; set; }    public SensorConfiguration()    {    }    public SensorConfiguration(string name, SensorType type, SensorLocation location)    {        Name = name;        Type = type;        Location = location;    }}序列化:        var topvessel = Sensors.TopVessel.Select(sensor =>            new SensorConfiguration(sensor.SensorName, sensor.Type, SensorLocation.TopVessel));        var manifold = Sensors.Manifold.Select(sensor =>            new SensorConfiguration(sensor.SensorName, sensor.Type, SensorLocation.Manifold));        var waferstage = Sensors.WaferStage.Select(sensor =>            new SensorConfiguration(sensor.SensorName, sensor.Type, SensorLocation.Manifold));        var sensorConfigurations = topvessel.Concat(manifold).Concat(waferstage).ToList();        var json = JsonConvert.SerializeObject(sensorConfigurations);我究竟做錯(cuò)了什么?該示例表明這是可能的...
查看完整描述

1 回答

?
森欄

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊

嘗試刪除[JsonArray]


所以你的代碼看起來(lái)像


public class SensorConfiguration

{

    [JsonProperty]

    public string Name { get; set; }

    [JsonConverter(typeof(StringEnumConverter))]

    public SensorType Type { get; set; }

    [JsonConverter(typeof(StringEnumConverter))]

    public SensorLocation Location { get; set; }


    public SensorConfiguration()

    {

    }


    public SensorConfiguration(string name, SensorType type, SensorLocation location)

    {

        Name = name;

        Type = type;

        Location = location;

    }

}


查看完整回答
反對(duì) 回復(fù) 2023-08-13
  • 1 回答
  • 0 關(guān)注
  • 188 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)