1

The JSON file has 2 parts (Nested) and I just could import the first one I don't know why, any idea for this? The first column from the second part showed me NULL in database

This is the JSON file format:

This is the JSON file format

My code is:

    public override void CreateNewOutputRows()
{
    /*
    Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
    For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
    */
    String jsonFileContent = File.ReadAllText(@"C:\Json XLM project SSIS\FileSample.JSON");
    JavaScriptSerializer js = new JavaScriptSerializer();
    List<Order> orders = js.Deserialize<List<Order>>(jsonFileContent);
    foreach (Order order in orders)
    {
        Output0Buffer.AddRow();
        Output0Buffer.TrackingNumber = order.TrackingNumber;
        Output0Buffer.LocalReferenceNumber = order.LocalReferenceNumber;
        Output0Buffer.TotalShipmentPieces = order.TotalShipmentPieces;
        Output0Buffer.TotalShipmentValue = order.TotalShipmentValue;
        Output0Buffer.ShipmentCurrency = order.ShipmentCurrency;
        Output0Buffer.ShipmentGrossWeight = order.ShipmentGrossWeight;
        Output0Buffer.ShipmentNetWeight = order.ShipmentNetWeight;
        Output0Buffer.BorderTransportMode = order.BorderTransportMode;
        Output0Buffer.ConveyanceDetail = order.ConveyanceDetail;
        Output0Buffer.TransportId = order.TransportId;
        Output0Buffer.Region = order.Region;
        Output0Buffer.WarehouseLocation = order.WarehouseLocation;
        Output0Buffer.InvoiceNumber = order.InvoiceNumber;
        Output0Buffer.InvoiceDate = order.InvoiceDate;
        Output0Buffer.ItemCategoryId = order.ItemCategoryId;
        Output0Buffer.InsuredValue = order.InsuredValue;
        Output0Buffer.SoldByShipmentPartyAddressId =     order.SoldByShipmentPartyAddressId; 

    }
}

Thanks in advance.

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Leo
  • 19
  • 4
  • 1
    Post the JSON string, not images of the JSON string. `JavaScriptSerializer` is obsolete too. It was only used as a stop-gap measure. Even ASP.NET Web API uses Json.NET. – Panagiotis Kanavos Feb 06 '19 at 16:57
  • 1
    Which SQL Server version are you using? If you use 2016 or later it's probably easier to load the file into a staging table and then use the JSON functions to parse it – Panagiotis Kanavos Feb 06 '19 at 17:00
  • I'm using SQL Server version 2008 R2 – Leo Feb 06 '19 at 17:16

0 Answers0