Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 521.3k

How to convert to JSon format

Dec 21 2022 8:54 AM

Hi

  I have below coe & i want to convert it into Json format shown below

objShippingOrdr.OrderNo = txtOrderNo.Text;
            objShippingOrdr.PaymentType = ddlPaymentType.SelectedItem.Value;
            objShippingOrdr.OrderAmount = Convert.ToDecimal(txtOrderAmount.Text);
            objShippingOrdr.ConsigneeName = txtConsigneeName.Text;
            objShippingOrdr.ConsigneeAddress = txtConsigneeAddress.Text;
            objShippingOrdr.ConsigneeCity = txtConsigneeCity.Text;
            objShippingOrdr.ConsigneeState = txtConsigneeState.Text;
            objShippingOrdr.ConsigneePinCode = Convert.ToInt32(txtConsigneePinCode.Text);
            objShippingOrdr.ConsigneePhone = Convert.ToInt32(txtConsigneePhone.Text);

            objShippingOrdr.PickupName = txtPickupName.Text;
            objShippingOrdr.PickupAddress = txtPickupAddress.Text;
            objShippingOrdr.PickupCity = txtPickupCity.Text;
            objShippingOrdr.PickupState = txtPickupState.Text;
            objShippingOrdr.PickupPinCode = Convert.ToInt32(txtPickupPinCode.Text);
            objShippingOrdr.PickupPhone = Convert.ToInt32(txtPickupPhone.Text);

*********************
var body = @"{" + "\n" +
@"    ""order_number"": ""#001""," + "\n" +
@"    ""shipping_charges"": 40," + "\n" +
@"    ""discount"": 100," + "\n" +
@"    ""cod_charges"": 30," + "\n" +
@"    ""payment_type"": ""cod""," + "\n" +
@"    ""order_amount"": 1000," + "\n" +
@"    ""package_weight"": 300," + "\n" +
@"    ""package_length"": 10," + "\n" +
@"    ""package_breadth"": 10," + "\n" +
@"    ""package_height"": 10," + "\n" +
@"    ""consignee"": {" + "\n" +
@"        ""name"": ""Customer Name""," + "\n" +
@"        ""address"": ""190, ABC Road""," + "\n" +
@"        ""address_2"": ""Near Bus Stand""," + "\n" +
@"        ""city"": ""Mumbai""," + "\n" +
@"        ""state"": ""Maharastra""," + "\n" +
@"        ""pincode"": ""400001""," + "\n" +
@"        ""phone"": ""9999999999""" + "\n" +
@"    }," + "\n" +
@"    ""pickup"": {" + "\n" +
@"        ""warehouse_name"": ""warehouse 1""," + "\n" +
@"        ""name"" : ""Vikalp Sharma""," + "\n" +
@"        ""address"": ""140, MG Road""," + "\n" +
@"        ""address_2"": ""Near metro station""," + "\n" +
@"        ""city"": ""Gurgaon""," + "\n" +
@"        ""state"": ""Haryana""," + "\n" +
@"        ""pincode"": ""122001""," + "\n" +
@"        ""phone"": ""9999999999""" + "\n" +
@"    }," + "\n" +
@"    ""order_items"": [" + "\n" +
@"        {" + "\n" +
@"            ""name"": ""product 1""," + "\n" +
@"            ""qty"": ""18""," + "\n" +
@"            ""price"": ""100""," + "\n" +
@"            ""sku"": ""sku001""" + "\n" +
@"        }" + "\n" +
@"    ]" + "\n" +
@"}";

Thanks


Answers (1)