Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法反序列化JSON对象类型需要JSON数组(例如[1,2,3])才能正确反序列化_C#_Json_Json.net - Fatal编程技术网

C# 无法反序列化JSON对象类型需要JSON数组(例如[1,2,3])才能正确反序列化

C# 无法反序列化JSON对象类型需要JSON数组(例如[1,2,3])才能正确反序列化,c#,json,json.net,C#,Json,Json.net,我在处理JSON数组时遇到了一些问题,下面是我尝试过的。我也尝试过使用问题在于我的类没有正确的属性,结果还表明UPS api没有发送静态类型响应,每次都可能不同。。需要将新类反序列化为。我还没有找到一种使课堂灵活的方法看看右边“相关”下所有标题类似的帖子。没有确切的json,但您有一个数组,并试图反序列化为一个东西。您可以共享示例json吗 jsonResponse.RootObject deserializedResponse = JsonConvert.DeserializeObject&l

我在处理JSON数组时遇到了一些问题,下面是我尝试过的。我也尝试过使用
问题在于我的类没有正确的属性,结果还表明UPS api没有发送静态类型响应,每次都可能不同。。需要将新类反序列化为。我还没有找到一种使课堂灵活的方法

看看右边“相关”下所有标题类似的帖子。没有确切的json,但您有一个数组,并试图反序列化为一个东西。您可以共享示例json吗
jsonResponse.RootObject deserializedResponse = JsonConvert.DeserializeObject<jsonResponse.RootObject>(Globals.jsonResponse);
namespace QuantumView
{
    [JsonObjectAttribute]
    class jsonResponse
    {
        public class TransactionReference
        {
            public string CustomerContext { get; set; }
        }

        public class Response
        {
            public TransactionReference TransactionReference { get; set; }
            public string ResponseStatusCode { get; set; }
            public string ResponseStatusDescription { get; set; }
        }

        public class SubscriptionStatus
        {
            public string Code { get; set; }
            public string Description { get; set; }
        }

        public class StatusType
        {
            public string Code { get; set; }
            public string Description { get; set; }
        }

        public class Address
        {
            public string AddressLine1 { get; set; }
            public string City { get; set; }
            public string StateProvinceCode { get; set; }
            public string PostalCode { get; set; }
            public string CountryCode { get; set; }
        }

        public class Shipper
        {
            public string Name { get; set; }
            public string ShipperNumber { get; set; }
            public Address Address { get; set; }
        }

        public class Address2
        {
            public string ConsigneeName { get; set; }
            public string AddressLine1 { get; set; }
            public string AddressLine2 { get; set; }
            public string City { get; set; }
            public string StateProvinceCode { get; set; }
            public string PostalCode { get; set; }
            public string CountryCode { get; set; }
        }

        public class ShipTo
        {
            public string AttentionName { get; set; }
            public string PhoneNumber { get; set; }
            public Address2 Address { get; set; }
        }

        public class ReferenceNumber
        {
            public string Number { get; set; }
            public string Value { get; set; }
        }

        public class Service
        {
            public string Code { get; set; }
        }

        public class Activity
        {
            public string Date { get; set; }
            public string Time { get; set; }
        }

        public class Dimensions
        {
            public string Length { get; set; }
            public string Width { get; set; }
            public string Height { get; set; }
        }

        public class UnitOfMeasurement
        {
            public string Code { get; set; }
        }

        public class DimensionalWeight
        {
            public UnitOfMeasurement UnitOfMeasurement { get; set; }
            public string Weight { get; set; }
        }

        public class PackageWeight
        {
            public string Weight { get; set; }
        }

        public class ReferenceNumber2
        {
            public string Number { get; set; }
            public string Value { get; set; }
        }

        public class PackageServiceOptions
        {
            public string COD { get; set; }
        }
        [JsonArray]
        public class Package
        {
            public Activity Activity { get; set; }
            public Dimensions Dimensions { get; set; }
            public DimensionalWeight DimensionalWeight { get; set; }
            public PackageWeight PackageWeight { get; set; }
            public string TrackingNumber { get; set; }
            public List<ReferenceNumber2> ReferenceNumber { get; set; }
            public PackageServiceOptions PackageServiceOptions { get; set; }
        }

        public class BillToAccount
        {
            public string Option { get; set; }
            public string Number { get; set; }
        }
        [JsonArray]
        public class Manifest
        {
            public Shipper Shipper { get; set; }
            public ShipTo ShipTo { get; set; }
            public List<ReferenceNumber> ReferenceNumber { get; set; }
            public Service Service { get; set; }
            public string PickupDate { get; set; }
            public string ScheduledDeliveryDate { get; set; }
            public string ScheduledDeliveryTime { get; set; }
            public string DocumentsOnly { get; set; }
            public Package Package { get; set; }
            public string ShipmentChargeType { get; set; }
            public BillToAccount BillToAccount { get; set; }
        }

        public class SubscriptionFile
        {
            public string FileName { get; set; }
            public StatusType StatusType { get; set; }
            public List<Manifest> Manifest { get; set; }
            public object Origin { get; set; }
        }
        [JsonArray]
        public class SubscriptionEvents
        {
            public string Name { get; set; }
            public string Number { get; set; }
            public SubscriptionStatus SubscriptionStatus { get; set; }

            public List<SubscriptionFile> SubscriptionFile { get; set; }
        }

        public class QuantumViewEvents
        {
            public string SubscriberID { get; set; }
            public SubscriptionEvents SubscriptionEvents { get; set; }
        }

        public class QuantumViewResponse
        {
            public Response Response { get; set; }
            public QuantumViewEvents QuantumViewEvents { get; set; }
            public string Bookmark { get; set; }
        }

        public class RootObject
        {
            public QuantumViewResponse QuantumViewResponse { get; set; }
        }
    }
}