C# JSON Parsing

前端 未结 2 505
猫巷女王i
猫巷女王i 2020-12-06 23:51

I have problems parsing some JSON data:

{
    \"title\": \"LED SIDE DIRECTION INDICATOR 9-33V CATEGORY 6, 19cm CABLE CHROME BASE  LED AUTO LAMPS\",
    \"us         


        
2条回答
  •  情书的邮戳
    2020-12-07 00:39

    If the fields of the json object are always the same, then you could use strong typed classes instead of dictionaries. The json serializer will serialize correctly to the following classes:

    private class MyJsonClass
    {
        public string title { get; set; }
        public UserPrice user_price { get; set; }
        public int local_quantity { get; set; }
        ...
    }
    
    private class UserPrice
    {
        public decimal inc_tax_value { get; set; }
        public decimal ex_tax_value { get; set; }
        ...
    }
    

提交回复
热议问题