How to deserialize json string to object list in c# dot

前端 未结 4 1592
你的背包
你的背包 2020-12-15 21:56

I am working with the following JSON string

{
\"transactions\": 
[
   {
    \"paymentcharge\":\"0.0\",
    \"amount\":352,
    \"id\":13418,
    \"shippingc         


        
4条回答
  •  醉梦人生
    2020-12-15 22:42

    Create a class as below
    By creating the list of class 'clsSalesTran' and a variable for 'Count'

    Note: JsonProperty is mandatory from your Json String

    public class SalesTransactions
    {
         [JsonProperty("transactions")]
         public List transactions {get;set;}
         public int count{get;set;}
    }
    

    Then you may use this class as below to deserialize

    SalesTransactions st = JsonConvert.DeserializeObject(inputString)
    

    Use the Deserialized object as below

    double paymentcharge = st.transactions[0].paymentcharge;
    

提交回复
热议问题