0

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.

qaguru
  • 81
  • 2
  • 5
  • duplicate? https://stackoverflow.com/questions/4535840/deserialize-json-object-into-dynamic-object-using-json-net – Thomas Koelle Dec 22 '22 at 14:06
  • [Using JsonConvert.DeserializeObject to deserialize Json](https://stackoverflow.com/questions/11126242/), [Deserialize Json object into dynamic object](https://stackoverflow.com/questions/4535840/), many others... – Dour High Arch Dec 22 '22 at 15:34

1 Answers1

0

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

double value = obj.Order[0].Price;
vhr
  • 1,528
  • 1
  • 13
  • 21