jsonpickleJS/handlers.js
raw| 1 | define( function () { |
| 2 | // each can define -- flatten; restore; post_restore. Note that if the object has sub objects |
| 3 | // in restore, then they MUST be restored just to keep the object count valid. No skipping... |
| 4 | var handlers = { |
| 5 | 'fractions.Fraction': { |
| 6 | restore: function(obj) { |
| 7 | return obj._numerator / obj._denominator; |
| 8 | } |
| 9 | }, |
| 10 | }; |
| 11 | |
| 12 | if (typeof jsonpickle != 'undefined') { |
| 13 | jsonpickle.handlers = handlers; |
| 14 | } |
| 15 | return handlers; |
| 16 | }); |