Emulating XML Schema in JSON

Continuing along the same path that resulted in JCS (JSON Cleartext Signature), the next frontier is JSON validation.
Although there are efforts creating schema support in JSON, I think they only apply to really complex systems which may equally well use XML.

So instead I have taken a programmatic approach, where automatically instantiated classes perform de-serialization and self-validation.

Together with a parser that also notes if JSON data isn't de-serialized (forgotten or illegal), you get a minimalist system depending on two predefined properties (@context and @qualifier), which in essence mimic XML's namespace and top-level element:

Sample objects:
https://code.google.com/p/openkeystore/source/browse/javascript/trunk/src/decoder/test/decoder-test.js

The class factory:
https://code.google.com/p/openkeystore/source/browse/javascript/trunk/src/jsonparser/JSONDecoderCache.js

How does this relate to web-payments you may wonder?
Well, message validation must be performed in some way and it might affect the messages themselves which it did in my case.

Regards,
Anders

Received on Wednesday, 15 January 2014 12:04:22 UTC