@betit/orion-node-sdk
Version:
SDK for orion
34 lines • 757 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
const debug = utils_1.debugLog('orion:codec:json');
/**
* JavaScript Object Notation, a lightweight data-interchange format.
*/
class JsonCodec {
constructor() {
this.encoding = 'utf8';
this.contentType = 'application/json';
}
/**
* Encode data.
*/
encode(data) {
debug('encode');
return JSON.stringify(data);
}
/**
* Decode data.
*/
decode(data) {
debug('decode');
try {
return JSON.parse(data);
}
catch (e) {
return null;
}
}
}
exports.JsonCodec = JsonCodec;
//# sourceMappingURL=json.js.map