How can I deserialize this JSON (Unexpected character encountered while parsing value)?

I have no experience with deserialization, and am trying to figure out how to get this working. I am using JSON.NET, and attempts to deserialize come up with the following: Unexpected character encountered while parsing value: c. path '', line 0 position 0

I am currently working with the following JSON object:

{

            "id":"1024",

            "OrderNumber":"1024",

            "OrderDate":"11/17/2014 2:20:35 PM",

            "ShippingMethod":"USPS Priority Mail",

            "BillingAddress":{

                        "FirstName":"Joe",

                        "LastName":"Test1",

                        "Company":"",

                        "AddressLine1":"9 Hispalis Rd",

                        "AddressLine2":"",

                        "City":"Andover",

                        "State":"MA",

                        "Postcode":"01810",

                        "Country":"US",

                        "Email":"Joe@Test.com",

                        "Phone":"9785553902"

            },

            "ShippingAddress":{

                        "FirstName":"Joe",

                        "LastName":"Test",

                        "Company":"",

                        "AddressLine1":"9 Hispalis Rd",

                        "AddressLine2":"",

                        "City":"Andover",

                        "State":"MA",

                        "Postcode":"01810",

                        "Country":"US",

                        "Email":"Joe@Test.com",

                        "Phone":"9785553902"

            },

            "UpdateAt":"11/17/2014 2:21:08 PM",

            "OrderStatus":"New",

            "TotalAmount":22.70,

            "PaidAmount":0.0,

            "ShippingAmount":6.95,

            "TaxAmount":0.00,

            "OrderItems":[{

                        "ProductSKU":"PF7977",

                        "Quantity":"1.00",

                        "Price":"15.75",

                        "Discount":"0.00"

            }],

            "HandlingInstructions":null,

            "SpecialInstructions":null,

            "PromotionCode":null,

            "SalesChannelId":"a57c68d2-c544-4f7a-8ed0-a39a00e2c1e0",

            "Shipments":[{

"id":"1018",

"Carrier":

"USPS",

"ShippingService":"Priority",

"Status":"Completed",

"Box1":"1010",

"TrackingNumber1":"9405510200882424054304",

"ShippedDate1":"12/11/2014 12:56:40 AM",

"Weight1":"3.00",

"WeightUnit1":"lbs"}],

"DropShipPurchaseOrders":[{

"id":"1000",

"SupplierName":"Baldwin Filters",

"ShippingService":"USPS Parcel Post",

"ShipTo":"Paul Quirnbach",

"ShipmentId":"1019",

"SKU1":"PF7977",

"Quantity1":"1.00",

"SKU2":"BT7349",

"Quantity2":"3.00"}]
}

Open in new window


Here is the PO Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace FreestyleAPI
{
    public class PO
    {
    [JsonProperty("id")]
    public int id { get; set; }

    [JsonProperty("OrderNumber")]
    public int OrderNumber { get; set; }

    [JsonProperty("OrderDate")]
    public DateTime OrderDate { get; set; }

    [JsonProperty("ShippingMethod")]
    public string ShippingMethod { get; set; }

    [JsonProperty("BillingAddress")]
    public BillingAddress BillingAddress { get; set; } //requires class

    [JsonProperty("ShippingAddress")]
    public ShippingAddress ShippingAddress { get; set; } //requires class

    [JsonProperty("UpdateAt")]
    public DateTime UpdateAt { get; set; }

    [JsonProperty("OrderStatus")]
    public string OrderStatus { get; set; }

    [JsonProperty("TotalAmount")]
    public decimal TotalAmount { get; set; }

    [JsonProperty("PaidAmount")]
    public decimal PaidAmount { get; set; }

    [JsonProperty("ShippingAmount")]
    public decimal ShippingAmount { get; set; }

    [JsonProperty("TaxAmount")]
    public decimal TaxAmount { get; set; }

    [JsonProperty("OrderItems")]
    public OrderItems[] OrderItems { get; set; } //requires class

    [JsonProperty("HandlingInstructions")]
    public string HandlingInstructions { get; set; }

    [JsonProperty("SpecialInstructions")]
    public string SpecialInstructions { get; set; }

    [JsonProperty("PromotionCode")]
    public string PromotionCode { get; set; }

    [JsonProperty("SalesChannelId")]
    public string SalesChannelId { get; set; }

    [JsonProperty("Shipments")]
    public Shipments[] Shipments { get; set; } //requires class

    [JsonProperty("DropShipPurchaseOrders")]
    public DropshipPurchaseOrders[] DropShipPurchaseOrders { get; set; } //requires class

}
}

Open in new window


Here is the deserialization code:

logger.Log("loadJSON:" + strfile);

            FileReference fileref = new FileReference();
            fileref.filename = strfile;

            PO POTest = new PO(); //instance of PO class

            fileref.isValid = false;
            //load the xml document
            #region
            try
            {
                POTest = JsonConvert.DeserializeObject<PO>(strfile);

                Console.WriteLine("success,loaded JSON");
                logger.Log("loaded JSON:" + strfile);

            }
            catch (Exception ex)
            {
                logger.Log("unable to load JSON doc:" + strfile + " " + ex.ToString());
}

Open in new window

Jordan JohnsonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
strfile contains a file path, not JSON data. I suspect you intended on passing the contents of that file?

POTest = JsonConvert.DeserializeObject<PO>(strfile);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.