UNPKG

@betit/orion

Version:

Pluggable microservice framework

34 lines (33 loc) 723 B
"use strict"; 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; } } } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = JsonCodec;