Save Dictionary to JSON file

What is the best way to convert a dcitionary into a format that can be saved as a JSON file?

Below is the desired JSON output.

{
“invoiceID”: “1234”,
“billTo”: “Acme Ltd.”
}

I can build the JSON manually by getting each key and value and formatting correctly with quotes, braces and commas, but there must be a better way.

Thanks for your help.

How about string strJson= JsonConvert.SerializeObject( Dictionary)

7 Likes