Apologies if this seems basic, but I have the following json
{
"id": "71e590d2-ab61-47ae-9ada-b9cedbf309bc",
"user_firstname": "Tommy",
"user_lastname": "Tester",
"user_displayname": "Tommy Tester",
"user_primary_email": "[email protected]"
}
I just want to convert this to a string in a C# function that is accepted by our system so
"{\"id\":\"71e590d2-ab61-47ae-9ada-b9cedbf309bc\",\"user_firstname\":\"Tommy\",\"user_lastname\":\"Tester\",\"user_displayname\":\"Tommy Tester\",\"user_primary_email\":\"[email protected]\"}"
I can do it manually using this online tool https://tools.knowledgewalls.com/jsontostring
I'd suggest you to use JSON library from Newtonsoft. You can install the library from NuGet Packet Manager.
Once installed you can convert your JSON object into a string just in one line by using the JsonConvert.ToString
method.
string myString = JsonConvert.ToString(yourJsonObject);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments