Hot swappable schemas?


We’d like to support hot swappable schemas in our solution long term. The idea is that we could add a new schema to a repository and not have to redeploy any code.

This requires serializing and deserializing the schema such that the editor could load it at runtime. I’ve been banging my head against the keyboard trying to make it work. Serializing the spec with Douglas Crockford’s cycling methods, works to get it over the wire. However, in my testing this fails to produce an identical schema when we try to instantiate a new one.

I looked at this discussion, but was not able to get it serializing at all using that method.

Thoughts? Advice? Am I crazy?


Definitely don’t try to serialize the Schema object itself—that’s an instance of a class, and there’s no robust way to serialize it.

You could try to serialize the spec you used to build the schema, though that may also contain functions (in the DOM parser and serializer properties) and thus won’t be serializeable as JSON. So you’ll either have to separate the DOM parsing logic from the schema (which is possible, if a little awkward), or load actual JavaScript code somehow.


Thanks for the reply Marjin, will take that into consideration and update this thread as it progresses.