semantic-network
Version:
A utility library for manipulating a list of links that form a semantic interface to a network of resources.
27 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonSerialiser = void 0;
var JsonSerialiser = /** @class */ (function () {
function JsonSerialiser() {
}
/**
* A replacer function to strip the state from a model
* see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
*/
JsonSerialiser.ToJsonReplacer = function (key, value) {
return key !== 'createForm' && key !== 'editForm' ? value : undefined;
};
/**
* Returns a representation from a model that is already hydrated and looks close as possible to what
* it looked like when it came over the wire. In this case, it removes the state attribute.
*
* @param resource
* @param space number of spaces in the pretty print JSON
*/
JsonSerialiser.toJson = function (resource, space) {
return JSON.stringify(resource, JsonSerialiser.ToJsonReplacer, space);
};
return JsonSerialiser;
}());
exports.JsonSerialiser = JsonSerialiser;
//# sourceMappingURL=jsonSerialiser.js.map