Subject: | JSON-RPC class identification support |
The JSON-RPC spec (http://www.json-rpc.org/) contains the following
provision to serialize class information:
---snip--
3. JSON Class hinting
There are only simple data types defined in JSON. To overcome this
problem in a JSON compatible way a special property for objects is
introduced.
{"__jsonclass__":["constructor", [param1, ], "prop1": ...}
The object is then instantiated using the constructor, passing in the
parameters. Once constructed the properties (prop1, ...) will be applied.
---snip---
I would like to see JSON::Syck be able to handle this. Perhaps the
ability to define two callbacks.
1) During dumping, given a blessed reference, get the [ "constructor",
param ] args back.
2) During loading, given when a hash where the __jsonclass__ key is
found, pass that hashref into a callback and get an object back.
I think this would help address any naming
convention/security/implementation concerns and leave it as open as
possible.
Does libsyck/JSON::Syck currently tackle structures depth-first?
Thanks,
Tyler