0

Not that much experience using json, I have read many topics on this but it seems like no one's got the same json structure that I'm working with so i cant seem to get the following items deserialized, basically i will be populating a listbox with all bucketName in the list as shown below, the json gets returned from a web request.

This currently holds all the json data:

var responseString = new StreamReader(responseList.GetResponseStream()).ReadToEnd();

And this is the content it holds:

{
    "buckets": 
    [
        {
            "accountId": "someweirdid",
            "bucketId": "4a48fe8875c6214145260818",
            "bucketInfo": {},
            "bucketName" : "Kitten-Videos",
            "bucketType": "allPrivate",
            "lifecycleRules": []
        },
        {
            "accountId": "uuhhmthisisarandomid",
            "bucketId" : "5b232e8875c6214145260818",
            "bucketInfo": {},
            "bucketName": "Puppy-Videos",
            "bucketType": "allPublic",
            "lifecycleRules": []
        },
        {
            "accountId": "ahhhanotherid",
            "bucketId": "87ba238875c6214145260818",
            "bucketInfo": {},
            "bucketName": "Vacation-Pictures",
            "bucketType" : "allPrivate",
            "lifecycleRules": []
        }
    ]
}

I need the bucketName item to be populated in a listbox, please any help, thanks.

Nekuskus
  • 143
  • 1
  • 11

1 Answers1

1

Try converting json object to C# and create a list which can be used to populate listbox

using Newtonsoft.Json;
...
var result = JsonConvert.DeserializeObject<T>(json);
Roshan
  • 873
  • 12
  • 33