I have a json of this type (product category) =

part_types: { 29662101: "Щетка стеклоочистителя", 29834101: "Молдинг лобового стекла", 30177101: "Стекло заднее", 43326101: "Стекло лобовое", 43334101: "Стекло форточки", 43335101: "Стекло боковое опускное", 43336101: "Стекло кузова боковое (не опускное)" } 

I deserialize through Json.Net, indicating that we have a dynamic class ( dynamic data = JsonConvert.DeserializeObject(Out) )

How to display all categories of goods, despite the fact that I do not know in advance which objects I need?

I do not know what to insert there:

 foreach (dynamic item in data.part_types) { checkedListBox1.Items.Add(item.НЕ ЗНАЮ ЧТО СЮДА ВСТАВИТЬ); } 

P / S I hope it will be clear :)

    1 answer 1

    If I understand correctly what you need, this is what will work. The real type of your item is JProperty (do not forget using Newtonsoft.Json.Linq; ). Therefore, should roll this:

     foreach (JProperty item in data.part_types) { string value = (string)item.Value; // у вас есть значение, делайте с ним, что хотите } 
    • What is p with you? - Andrei NOP
    • @Andrey: Ugh, typo, this is an item , of course. - VladD