ts-object-mapper
Version:
A TypeScript library to serialize and deserialize JSON objects
2 lines • 2.92 kB
JavaScript
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.ObjectMapper=r():e.ObjectMapper=r()}("undefined"!=typeof self?self:this,function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";r.__esModule=!0;var n=t(1),o=function(){function e(){}return e.getInstance=function(){return this.Instance||(this.Instance=new e),this.Instance},e.serialize=function(e,r){return void 0!==r?(Array,this.getInstance().serialize(e,r)):this.getInstance().serialize(e)},e.deserialize=function(e,r){return this.getInstance().deserialize(e,r)},e.deserializeArray=function(e,r){return this.getInstance().deserializeArray(e,r)},e.prototype.serialize=function(e,r){var t=this;return e instanceof Array?void 0!==r?e.map(function(e){return t.serializeObject(e,r)}):JSON.stringify(e.map(function(e){return t.serializeObject(e,Object)})):void 0!==r?this.serializeObject(e,r):JSON.stringify(this.serializeObject(e,Object))},e.prototype.deserialize=function(e,r){if("string"==typeof r){var t=void 0;try{t=JSON.parse(r)}catch(e){throw e instanceof SyntaxError?new n.ObjectMapperError("JSON syntax error: "+e.message,e):new n.ObjectMapperError("Unknown error",e)}return this.deserializeObject(e,t)}return this.deserializeObject(e,r)},e.prototype.deserializeArray=function(e,r){var t=this;if("string"==typeof r){var o=void 0;try{o=JSON.parse(r)}catch(e){throw e instanceof SyntaxError?new n.ObjectMapperError("JSON syntax error: "+e.message,e):new n.ObjectMapperError("Unknown error",e)}return o.map(function(r){return t.deserializeObject(e,r)})}return r.map(function(r){return t.deserializeObject(e,r)})},e.prototype.serializeObject=function(e,r){return new r},e.prototype.deserializeObject=function(e,r){return new e},e}();r.ObjectMapper=o},function(e,r,t){"use strict";var n,o=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])},function(e,r){function t(){this.constructor=e}n(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)});r.__esModule=!0;var i=function(e){function r(r,t){var n=e.call(this,r)||this;return n.name=n.constructor.name,n.message=r||"Unexpected error",Error.captureStackTrace(n,n.constructor),n.cause=t,n}return o(r,e),r}(Error);r.ObjectMapperError=i}]).ObjectMapper});
//# sourceMappingURL=ts-object-mapper.umd.min.js.map