I'm trying to load a json file in .NET Core. To do this I'm using the NewtonSoft
package. I successfully installed it, and
using NewtonSoft.Json;
produces no compiler errors. However when I try to load and parse a file as per their example, using
JObject obj = JObject.Parse(File.ReadAllText("file.json"));
I get a compiler error, telling me that JObject
does not exist. My suspicion is that there is a difference between .NET Framework and .NET Core implementation, but I don't know. In any case how do I load a json file using NewtonSoft
?
According official docs, JObject
class is in Newtonsoft.Json.Linq
namespace, so you need another import:
using Newtonsoft.Json.Linq;
JObject obj = JObject.Parse(File.ReadAllText("file.json"));
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