I have a string
string myString = "KTC|2020|MPD|18/01/2021|I|O|B|ALST|";
I need to convert to the following format.
string convertedJsonString="{"compCode":"KTC","accountYear":"2020","shipmentNumber":"MPD","shipmentDate":"18/01/2021","shipmentType":"I","shipmentCategory":"M","fromLevelCode":"B","fromLocationCode":"ALST"}";
When I tried to write the code like the following,
string[] inputArray = input.Split("|");
string jsonString = @"{"+ " compCode "+ ":" + inputArray[0];
jsonString += "," + "accountYear" + ":" + inputArray[1] + "}";
I am getting the string like the following
{ compCode :KTC,accountYear:2020} Not in the required format.
Can you please give me some idea about how we can achieve this?