recime-bot-runtime
Version:
This runtime is intended to run inside a micro-service container with platform specific integration and module interpreter.
40 lines (39 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var query = require("querystring");
var MsgObject = /** @class */ (function () {
function MsgObject() {
}
MsgObject.parse = function (body) {
var isObject = function (obj) {
return obj.constructor === Object;
};
var regExp = new RegExp(/<xml>[\s\S]*?<\/xml>/g);
if (regExp.test(body)) {
return body;
}
try {
// debug
if (isObject(body)) {
return body;
}
else {
var json = JSON.parse(body);
if (Object.keys(json).length > 0) {
return json;
}
return body;
}
}
catch (ex) {
var obj = query.parse(body);
if (Object.keys(obj).length > 0) {
return obj;
}
return body;
}
};
;
return MsgObject;
}());
exports.MsgObject = MsgObject;