I have JSON returned from a server, and I would like to validate it against a JSON Schema (probably draft V3, can change though).
I thought that perhaps NSDictionary would have the functionality, but it doesn't seem to, here is my attempt:
[self.dictionary ]
(where dictionary is an NSDictionary)
There weren't any methods for validating the NSDictionary against a JSON schema that I could find. How do I do this?
Please note that you can write C and C++ in objective-c, hence these tags being present in the question.
Objective-C is a superset of C. JSON Schema site lists a C library wjelement, you can adapt it.
The example function call is
WJESchemaValidate(schema, json, schema_error, schema_load, NULL, format)
You'll need to supply a C string, rather than NSString, naturally.
Note: after I wrote the answer, I realised you were fine with pure C from the start :)
After not finding a satisfactory answer to this question - I went away and developed my own schema validator in native Objective-c here: https://github.com/samskiter/KiteJSONValidator
I've just got it passing all the tests in the JSON-Schema test suite so I've released v0.1.
It's released under the MIT license so I hope it's useful to someone...
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