Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile-time validation for Json schemas #6

Open
jonalmeida opened this issue Nov 4, 2014 · 3 comments
Open

Compile-time validation for Json schemas #6

jonalmeida opened this issue Nov 4, 2014 · 3 comments

Comments

@jonalmeida
Copy link

Json.NET has a great schema validator which can be used for schemas we set. It can be installed with NuGet as well.

This is an example:

JsonSchema schema = JsonSchema.Parse(@"{
  'type': 'object',
  'properties': {
    'name': {'type':'string'},
    'hobbies': {'type': 'array'}
  }
}");

JObject person = JObject.Parse(@"{
  'name': 'James',
  'hobbies': ['.NET', 'LOLCATS']
}");

bool valid = person.IsValid(schema);
// true
@alexanderdean
Copy link
Member

Mmm, that's nice. This would make an awesome VisualStudio plugin no?

@jonalmeida
Copy link
Author

I'm not entirely sure if it exists. I'll search around! Came across this in another project and it seemed like a neat use case for the .NET tracker.

@jonalmeida
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants