I'm trying to write a web API that includes the newtonsoft JSON.net components.
My code is pretty straight-forward:
public object GetJsonFile(int id = 1) {
using (StreamReader r = new StreamReader(myJsonFile)) {
string json;
// todo: build logic to only grab latest when an id is supplied
json = r.ReadToEnd();
object jsonObject = JsonConvert.DeserializeObject(json);
return jsonObject;
}
When testing the page, I get the dreaded "Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself." error.
I've done my share of digging, and everyone seems to recommend to un-check "Reuse types in all referenced assemblies", but that only seems to be used in the case of Service References, which my project does not use. I did find the place to do this, but seeing I don't have a service to reference, I cannot configure it.
I'm not that at home in Visual Studio, so please go easy on me ;)