CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string json = @"
{
""billingAddress"": {
""zip"": ""64001340"",
""state"": ""PI"",
""number"": ""3443"",
""status"": ""ACTIVE"",
""firstName"": ""Fulano"",
""telephone"": {
""type"": ""billing"",
""number"": ""88112244""
},
""neighbourhood"": ""Centro""
},
""clientId"": ""cliente3"",
""documents"": [
{
""type"": ""cpf"",
""number"": ""12345678901""
}
],
""fulfillments"": {
""F1"": {
""id"": ""F1"",
""orderId"": ""4017116"",
""channelId"": ""channel2"",
""clientId"": ""cliente3"",
""locationId"": ""708"",
""shipment"": {
""method"": ""Economica"",
""carrierName"": ""Transportadora""
},
""status"": ""CANCELED"",
""type"": ""SHIPMENT"",
""enablePrePicking"": false,
""items"": {
""03.64.0005_11_10"": {
""sku"": ""03.64.0005_11_10"",
""quantity"": 0,
""stockType"": ""PHYSICAL"",
""orderedQuantity"": 1,
""returnedQuantity"": 0,
""canceledQuantity"": 1,
""itemType"": ""OTHER"",
""presale"": false,
""enablePicking"": true
},
""18.06.0220_48_2"": {
""sku"": ""18.06.0220_48_2"",
""quantity"": 0,
""stockType"": ""PHYSICAL"",
""orderedQuantity"": 1,
""returnedQuantity"": 0,
""canceledQuantity"": 1,
""itemType"": ""OTHER"",
""presale"": false,
""enablePicking"": true
}
}
},
""F2"": {
""id"": ""F2"",
""orderId"": ""4017116"",
""channelId"": ""channel2"",
""clientId"": ""cliente3"",
""locationId"": ""003"",
""operator"": {
""id"": ""5188"",
""name"": ""Loja da Vila""
},
""ownership"": ""oms"",
""shipment"": {
""method"": ""Economica"",
""carrierName"": ""Transportadora""
},
""status"": ""SHIPPING_READY"",
""type"": ""SHIPMENT"",
""enablePrePicking"": true,
""items"": {
""18.04.1465_01_3"": {
""sku"": ""18.04.1465_01_3"",
""quantity"": 1,
""stockType"": ""PHYSICAL"",
""orderedQuantity"": 1,
""returnedQuantity"": 0,
""canceledQuantity"": 0,
""itemType"": ""OTHER"",
""presale"": false,
""enablePicking"": true
},
""18.16.0630_13_10"": {
""sku"": ""18.16.0630_13_10"",
""quantity"": 1,
""stockType"": ""PHYSICAL"",
""orderedQuantity"": 1,
""returnedQuantity"": 0,
""canceledQuantity"": 0,
""itemType"": ""OTHER"",
""presale"": false,
""enablePicking"": true
}
}
}
},
""createdAt"": ""2019-06-08T21:41:12Z"",
""updatedAt"": ""2019-06-08T21:41:12Z""
}";
var root = JsonConvert.DeserializeObject<RootObject>(json);
foreach (var ff in root.fulfillments.Values)
{
Console.WriteLine("ID: " + ff.id);
Console.WriteLine("Client ID: " + ff.clientId);
Console.WriteLine("Order ID: " + ff.orderId);
Console.WriteLine("Location ID: " + ff.locationId);
Console.WriteLine("Status: " + ff.status);
Console.WriteLine("Items:");
foreach (var item in ff.items.Values)
{
Console.WriteLine();
Console.WriteLine(" SKU: " + item.sku);
Console.WriteLine(" Quantity: " + item.quantity);
Console.WriteLine(" Ordered Quantity: " + item.orderedQuantity);
Console.WriteLine(" Canceled Quantity: " + item.canceledQuantity);
}
Console.WriteLine("--------------------");
}
}
}
public class RootObject
{
public BillingAddress billingAddress { get; set; }
public string clientId { get; set; }
public List<Document> documents { get; set; }
public Dictionary<string, Fulfillment> fulfillments { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
}
public class BillingAddress
{
public string zip { get; set; }
public string state { get; set; }
public string number { get; set; }
public string status { get; set; }
public string firstName { get; set; }
public Telephone telephone { get; set; }
public string neighbourhood { get; set; }
}
public class Telephone
{
public string type { get; set; }
public string number { get; set; }
}
public class Document
{
public string type { get; set; }
public string number { get; set; }
}
public class Fulfillment
{
public string id { get; set; }
public string orderId { get; set; }
public string channelId { get; set; }
public string clientId { get; set; }
public string locationId { get; set; }
public Operator @operator { get; set; }
public string ownership { get; set; }
public Shipment shipment { get; set; }
public string status { get; set; }
public string type { get; set; }
public bool enablePrePicking { get; set; }
public Dictionary<string, Item> items { get; set; }
}
public class Operator
{
public string id { get; set; }
public string name { get; set; }
}
public class Shipment
{
public string method { get; set; }
public string carrierName { get; set; }
}
public class Item
{
public string sku { get; set; }
public int quantity { get; set; }
public string stockType { get; set; }
public int orderedQuantity { get; set; }
public int returnedQuantity { get; set; }
public int canceledQuantity { get; set; }
public string itemType { get; set; }
public bool presale { get; set; }
public bool enablePicking { get; set; }
}