Reputation: 177
I am trying to experiment with JSON schema validation. I am using the basic example for the schema on the JSON.NET Help page. I get the exception
System.MethodAccessException: Attempt by method
'Newtonsoft.Json.Schema.JSchema.Parse(System.String)' to access method
'Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(System.Object, System.String)' failed
My code is below
[TestMethod]
public void prettySimple()
{
string schemaJson = @"{
'type': 'object',
'properties': {
'name': {'type':'string'},
'hobbies': {
'type': 'array',
'items': {'type':'string'}
}
}
}";
JSchema schema = JSchema.Parse(schemaJson);
}
Upvotes: 1
Views: 1692
Reputation: 5445
Sounds like a package mismatch between Newtonsoft.Json and Newtonsoft.Json.Schema.
Newtonsoft.Json.Schema relies on Newtonsoft.Json version>= 6.0.8. So make sure it is up to date in your project.
I installed Newtonsoft.Json first and then the schema package and code ran fine for me.
My packages config:
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="Newtonsoft.Json.Schema" version="1.0.8" targetFramework="net45"/>
</packages>
Upvotes: 1