CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
var json=@"
[
{
""status"": ""Produzido (Codigo 3)"",
""estabelecimento_id"": 18,
""cliente_nome"": ""Marcos Manfrin"",
""estabelecimento"": ""Aquaria"",
""formas_de_pagamentos"": [
{
""valor_final"": ""69.00"",
""valor_total"": ""120.00"",
""tipo"": ""Dinheiro""
},
{
""valor_final"": ""69.00"",
""valor_total"": ""120.00"",
""tipo"": ""Débito Visa""
}
],
""apto"": ""402"",
""pedido_id"": 35370,
""data_venda"": ""07/06/2017"",
""items"": [
{
""quantidade"": 4,
""nome"": ""FOTO EM ARQUIVO DIGITAL"",
""valor_custo"": ""1.00"",
""observacoes"": ""Mandar para esse e-mail: [email protected]"",
""descricao"": """",
""produto_id"": 78693,
""valor_venda"": ""20.00""
},
{
""quantidade"": 2,
""nome"": ""FOTO EM ARQUIVO DIGITAL"",
""valor_custo"": ""1.00"",
""observacoes"": ""Mandar para esse e-mail: [email protected]"",
""descricao"": """",
""produto_id"": 78694,
""valor_venda"": ""20.00""
}
],
""comanda"": ""2103"",
""fotografo_id"": 36,
""fotografo"": ""Jaasiel Oliveira"",
""codigo"": ""C819F0""
}
]
";
var PedidosApi = JsonConvert.DeserializeObject<List<Comanda>>(json);
Console.WriteLine(PedidosApi[0].cliente_nome);
}
}
public class FormasDePagamento
{
public string valor_final { get; set; }
public string valor_total { get; set; }
public string tipo { get; set; }
}
public class Item
{
public int quantidade { get; set; }
public string nome { get; set; }
public string valor_custo { get; set; }
public string observacoes { get; set; }
public string descricao { get; set; }
public int produto_id { get; set; }
public string valor_venda { get; set; }
}
public class Comanda
{
public string status { get; set; }
public int estabelecimento_id { get; set; }
public string cliente_nome { get; set; }
public string estabelecimento { get; set; }
public List<FormasDePagamento> formas_de_pagamentos { get; set; }
public string apto { get; set; }
public int pedido_id { get; set; }
public string data_venda { get; set; }
public List<Item> items { get; set; }
public string comanda { get; set; }
public int fotografo_id { get; set; }
public string fotografo { get; set; }
public string codigo { get; set; }
}