0
I’m trying to do something that gives me a way out of this:
[
{
"Nome": "João",
"Comprou": [
"Carro": "Sedan", "Preco": "12000",
"Moto": "Honda", "Preco": "8000"
]
}
]
For this I use List and to save use JSON.net. The problem is that I am not able to put one key inside another. I tried this way:
public class Cliente
{
public string Nome { get; set; }
public string[] Comprou { get; set; }
}
public static List<Cliente> Clientes = new List<Cliente>();
I don’t know how to assign one value within another. I want to take the products and put them in a listbox for the particular customer who is selected in another listbox. I tried using foreach:
Cliente cliente = Clientes[listaClientes.SelectedIndex];
foreach (var produto in cliente.Comprou)
{
listaProdutosComprados.Items.Add(produto);
}
I wanted to put the values as "Name" and "Price" as I did with the client so that I could display these values in a label or textbox. I am developing this project in C# with a Winforms application.
Hello! Welcome to SOPT. Which library is used to serialize/deserialize?
– Omni
@Omni Hello! Thank you for being interested in helping me solve my problem. I am using JSON.net
– M. Victor