How do add comma between two json objects

Posted by Suneel161 under C# on 8/5/2015 | Points: 10 | Views : 705 | Status : [Member] | Replies : 1
Hi ,

How do add comma between two json objects..
im getting below string from client and how to deserialize the object.

{\"Amount\":28,\"Plan\":\"2011-10-22\",\"validity\":\"Tom\"}{\"Amount\":28,\"Plan\":\"2011-10-22\",\"validity\":\"Tom\"}

Regards,
Suneel




Responses

Posted by: Rajayadav on: 8/21/2015 [Member] Starter | Points: 25

Up
0
Down
Hi,
Try this


string a = "{\"Amount\":28,\"Plan\":\"2011-10-22\",\"validity\":\"Tom\"}{\"Amount\":28,\"Plan\":\"2011-10-22\",\"validity\":\"Tom\"} ";
int comma = a.IndexOf('}');
string b = a;
if (comma != -1)
{
b = a.Substring(0, comma);
b = a.Insert(comma+1, ",");
}
Console.WriteLine(b);

Thanks
-Raja

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response