Want to deserialize Json in list and save to database.
public class APICallsResponse
{
public string CODE { get; set; }
public string STATUS { get; set; }
public string MESSAGE { get; set; }
public string TOTAL_RECORDS { get; set; }
public string RESPONSE { get; set; }
public string UNIQUE_QUERY_ID { get; set; }
public string QUERY_TYPE { get; set; }
public string QUERY_TIME { get; set; }
public string SENDER_NAME { get; set; }
public string SENDER_MOBILE { get; set; }
public string SENDER_EMAIL { get; set; }
public string SUBJECT { get; set; }
public string SENDER_COMPANY { get; set; }
public string SENDER_ADDRESS { get; set; }
public string SENDER_CITY { get; set; }
public string SENDER_STATE { get; set; }
public string SENDER_PINCODE { get; set; }
public string SENDER_COUNTRY_ISO { get; set; }
public string SENDER_MOBILE_ALT { get; set; }
public string SENDER_PHONE { get; set; }
public string SENDER_PHONE_ALT { get; set; }
public string SENDER_EMAIL_ALT { get; set; }
public string QUERY_PRODUCT_NAME { get; set; }
public string QUERY_MESSAGE { get; set; }
public string QUERY_MCAT_NAMEE { get; set; }
public string CALL_DURATIONE { get; set; }
public string RECEIVER_MOBILEE { get; set; }
}
Response:
{
"CODE": 200,
"STATUS": "SUCCESS",
"MESSAGE": "",
"TOTAL_RECORDS": 66,
"RESPONSE": [
{
"UNIQUE_QUERY_ID": "2472779",
"QUERY_TYPE": "W",
"QUERY_TIME": "2023-06-21 13:02:06",
"SENDER_NAME": "Golu k",
"SENDER_MOBILE": "+91-789790000",
"SENDER_EMAIL": "",
"SUBJECT": "Requirement for",
"SENDER_COMPANY": "",
"SENDER_ADDRESS": "Varanasi, Uttar Pradesh",
"SENDER_CITY": "Varanasi",
"SENDER_STATE": "Uttar Pradesh",
"SENDER_PINCODE": "",
"SENDER_COUNTRY_ISO": "IN",
"SENDER_MOBILE_ALT": "",
"SENDER_PHONE": "",
"SENDER_PHONE_ALT": "",
"SENDER_EMAIL_ALT": "",
"QUERY_PRODUCT_NAME": "Mini",
"QUERY_MESSAGE": "I want to buy Mini. Kindly send me price and other details.
<br>Probable Requirement Type : Business Use<br>",
"QUERY_MCAT_NAME": "Mini",
"CALL_DURATION": "",
"RECEIVER_MOBILE": ""
}
Below item = code does not work to deserialize. Want to insert one by one to table.
There is response tag want the data from that tag
lets start from basics.
option 1: (read json string as is)
which will deserialise to object correctly
then you can map and populate your DTO object from deserialized one and store to DB using your Data layer functionality (DAL)
Option 2 (different approach):
i would assume you need just a response object in this case you can read a RESPONSE JToken directly into RESPONSE class
this is an examle:
but you will not have data (we will ignore the top set of columns):