Serialization.js 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {Object2D} from "./Object2D";
  2. /**
  3. * Handles object serialization to and from JSON.
  4. *
  5. * All objects should implement serialization methods to serialize and load data from generic object.
  6. *
  7. * @class
  8. */
  9. function Serialization(){}
  10. /**
  11. * Serialize a object into JSON object. That can be written into a file, sent using HTTP request etc.
  12. *
  13. * Booth the object and all its children are serialized.
  14. *
  15. * Data has to be parsed into the correct object types before it can be used using the parse() method.
  16. *
  17. * @static
  18. * @param {Object2D} object Object to be serialized.
  19. * @return {Object} Serialized object data.
  20. */
  21. Serialization.serialize = function(object)
  22. {
  23. // TODO <ADD CODE HERE>
  24. };
  25. /**
  26. * Parse serialized object data into the proper data structures to be rendered into the screen.
  27. *
  28. * @static
  29. * @param {Object} data Object data loaded from JSON.
  30. * @return {Object2D} Parsed object data.
  31. */
  32. Serialization.parse = function(data)
  33. {
  34. // TODO <ADD CODE HERE>
  35. };
  36. export {Serialization};