-1

How to read a raw response and display as is as a string. I am getting the response as below. How to extract the below response as string { "ProductDescription": { "ProductId": "1000222", "ProducName": "iphone13Case" }, "ProductDetails":{ "ProductDetails": { "ProductId": "1000222", "ProducCode": "Apple13", "ProducName": "iphone13Case", "ProductColor": "Red", "ProductModel": "iPhonePro" } } }

public Class ProductDescription
{
  public string ProductId;  
  Public string ProducName;
}

public Class ProductDetails
{
  public string ProductId;
  public string ProducCode;
  Public string ProducName;
  Public string ProductColor;
  Public string ProductModel;
}

Public Class ProductOrderDetails
{
  public ProductDetails prodDetails;
  public ProductDescription prodDescription
}

ProductOrderDetails response = RestApiMethod(param1, param2);
Buddy26
  • 39
  • 1
  • 6

1 Answers1

0

I got the answer. I am using Newtonsoft. responseString will now contain the response as a string with indentation.

var responseString = JsonConvert.SerializeObject(response, Formatting.Indented);
buddemat
  • 4,552
  • 14
  • 29
  • 49
Buddy26
  • 39
  • 1
  • 6