Jump to content
SupereeDuperee

Need Help with C# Class for ApiIfDoneDTO JSON Object

Recommended Posts

An ApiIfDoneDTO JSON text is given below. The Child Items "Stop" and "Limit" are of type "ApiStopLimitOrderDTO

{
   "IfDone":[
      {
         "Stop":{
            "OrderId":778252070,
            "StatusReason":1,
            "Status":2,
            "OrderTypeId":2,
            "Price":0,
            "Quantity":1000,
            "TriggerPrice":1.36261,
            "CommissionCharge":0,
            "IfDone":[
               
            ],
            "GuaranteedPremium":0,
            "OCO":null,
            "AssociatedOrders":{
               "Stop":null,
               "Limit":null
            },
            "Associated":false
         },
         "Limit":{
            "OrderId":778252069,
            "StatusReason":1,
            "Status":2,
            "OrderTypeId":3,
            "Price":0,
            "Quantity":1000,
            "TriggerPrice":1.36661,
            "CommissionCharge":0,
            "IfDone":[
               
            ],
            "GuaranteedPremium":0,
            "OCO":null,
            "AssociatedOrders":{
               "Stop":null,
               "Limit":null
            },
            "Associated":false
         }
      }
   ]
}

My ApiIfDoneDTO class looks like :-

    public class ApiIfDoneDTO
    {
        #region	Public Properties & Private Members
        
        /// <summary>
        /// The price at which the stop order will be filled.
        /// </summary>
        public ApiStopLimitOrderDTO Stop { get; set; }

        /// <summary>
        /// The price at which the limit order will be filled.
        /// </summary>
        public ApiStopLimitOrderDTO Limit { get; set; }

        #endregion

        #region Constructors
        private void Initilize()
        {

        }

        public ApiIfDoneDTO()
        {
            Initilize();
        }
        #endregion
}

 

Problem is the above JSON text is providing an ARRAY but the ApiIfDoneDTO class has just TWO Properties - Stop and Limit. I cannot deserialize JSON text into ApiIfDoneDTO object withouth manually hacking the JSON Text.

Is there any C# Developer OR JSON Expert who can show me what would be a Class Object that will Deserialize into from the Above JSON text (using NewtonSoft.JsonConverter) ? I will appreciate your help.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×