Home > Blockchain >  I need to access a JSON object inside another object or ArrayList via using dynamic. How can I acces
I need to access a JSON object inside another object or ArrayList via using dynamic. How can I acces

Time:12-23

Here is my code.

    dynamic obj = JsonConvert.DeserializeObject(response);
    double value = obj.Price;

and here is my JSON data, I am trying grab the value that is inside Price. How would I access the value inside Price or even TotalPrice???

{
    "Order": [
        {
            "Number": "1",
            "Price": 1.99
        }
    ],
    "TotalPrice": 1.99
}

Please, any help is appreciated. Thank you.

CodePudding user response:

You need to 'select' your object from array named Order (using index), then its property:

double value = obj.Order[0].Price;
  • Related