I have found many examples of code for JSON.NET, but I am unable to make any of them run in Visual Studio (C#). Quite probably this is because I am missing something obvious in how to code.
Particularly frustrating is the example code in newtonsoft.com will not compile and run. For example http://www.newtonsoft.com/json/help/html/SerializeObject.htm contains code for 'Types' and 'Usage' but there are no using statements and I can't figure out how to put the code into a project in a way to make it work.
I am sure I am missing something basic I just can't figure it out. I have been Googling for an answer for three days. Can you help me?
Assuming that you have downloaded the Json.NET nuget package (or otherwise properly added Newtonsoft's package to your project and referenced it) the only using statement you need other than the standard ones visual studio adds for you is Newtonsoft.Json
Their code runs perfectly fine in a project of type console application with the following using's:
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
The only other thing you might want to do is add a Console.ReadLine(); at the end so that you can see the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With