簡體   English   中英

JavaScriptSerializer。 如何從JSON反序列化字符串數組?

[英]JavaScriptSerializer. How to deserialize a string array from JSON?

這是我用來反序列化的模型。

C#

public class Info
{
    public string description { get; set; }
    public string[] tags { get; set; }
}

這是我要反序列化的JSON。

JSON

{
    "description" : "aeiou",
    "tags" : [ "a", "e", "i", "o" ]
}

當我嘗試去散布JSON對象時,它將引發錯誤。 當我將標識符從string []更改為string時,它可以工作,但這不是預期的結果。 我也嘗試了List,但是沒有用。

嘗試這樣的課程,別忘了先更新列表

public class Info
{
    public string description { get; set; }
    public List<string> tags { get; set; }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM