Click here to Skip to main content
16,022,236 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi guys i need a little help here
here is my json

JSON
"offset": 0,
 "total": 5,
 "transactions": [
   {
     "amount": {
       "currency": "EUR",
       "formatted_value": "0,00 €",
       "raw_value": "0"
     },
     "content_type": "title",
     "date": "2023-08-12T00:58:50+02:00",
     "device_type": "HAC",
     "ext_ec_granted_contents": [],
     "privilege_infos": [],
     "title": "Rocket League®",
     "transaction_id": 50695546073,
     "transaction_type": "PURCHASE"
   },


so what i want is showing only Title which is
      "title": "Rocket League®",

and the value which is <pre>        "formatted_value": "0,00 €",


so i tried this

public class getData
       {

           public int total { get; set; }

                public List<_DataTransection> transactions { get; set; }


       }
       public class _DataTransection
       {

           public string title { get; set; }
           public List<_Amount> amount { get; set; }

       }


       public class _Amount
       {
           public string raw_value { get; set; }
       }


getData account = JsonConvert.DeserializeObject<getData>(result);


transection list is fine , it shows me the
"title": "Rocket League®",
but it won't show me the value i don't know why

What I have tried:

This fixed my problem ||

public class _DataTransection
    {
   //     public string amount { get; set; }

        public string title { get; set; }
        public Amount amount { get; set; }

    }


    public class Amount
    {
        public string formatted_value { get; set; }
    }
Posted
Updated 28-Jul-24 22:37pm
v4
Comments
Ashkan X 29-Jul-24 4:39am    
ok now i'm going to fix it i didn't mean it tbh and i'm not looking for any reward for replying question here and accepting
now i remove the reply and improve my question haha there is no need to be aggressive i just found the problem right after i send the question , i was looking for the answer for few hours but i couldn't solve it . <3 XD
Pete O'Hanlon 29-Jul-24 5:19am    
Personally speaking, I'm fine with you posting the solution as an answer. You don't have to accept it, the simple fact that you've posted it should be enough.
Richard Deeming 29-Jul-24 5:45am    
Posting the question and then immediately posting (and accepting) the solution reeks of rep-point hunting.

Even if, in this instance, it turned out to be a case of Rubber Duck Debugging[^] instead. :)
Pete O'Hanlon 29-Jul-24 8:06am    
That's why I said it doesn't have to be accepted.
Ashkan X 29-Jul-24 6:51am    
Got it thanks.

1 solution

The OP managed to solve the problem, which was down to a misunderstanding about the deserialization of the data, namely that the shape of the class must match the shape of the data if you want to see values mapped in to the appropriate property. He's sorted it now, as documented in the question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900