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:

The class factory:

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.


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