Loop through dynamic object RRS feed

  • Question

  • Hi,

    I have below code:

    // send notification;
    var notification_client = new HttpClient();
    notification_client.BaseAddress = new Uri("https://www.domain.com/notifications.php");
    var notification_content = new FormUrlEncodedContent(new[]
        new KeyValuePair<string, string>("category", "ALERT")
    var notification_response = await client.PostAsync("https://www.domain.com/notifications.php", notification_content);
    var notification_result = await notification_response.Content.ReadAsStringAsync();
    dynamic notification_data = JsonConvert.DeserializeObject(notification_result);
    foreach (notification_data)

    Now I want to loop through the dynamic object notification_data to get the notification_email

    When it's just a single row I am able to get it like this:


    Kindly help..



    Wednesday, October 2, 2019 11:18 AM

All replies

  • If it is an array, then try this:

       foreach( var d in notification_data )


          string notification_email = d.notification_email;


          . . .



    If wrong guess, then try something else of show details (an example of notification_result).


    Wednesday, October 2, 2019 1:28 PM