UNPKG

unmock-core

Version:

[![npm](https://img.shields.io/npm/v/unmock-core.svg)][npmjs] [![CircleCI](https://circleci.com/gh/unmock/unmock-js.svg?style=svg)](https://circleci.com/gh/unmock/unmock-js) [![codecov](https://codecov.io/gh/unmock/unmock-js/branch/dev/graph/badge.svg)](h

19 lines 676 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class JSONSerializer { serialize(json) { const contentType = json.headers ? json.headers["Content-Type"] || json.headers["content-type"] : undefined; if (contentType && typeof contentType === "string" && contentType.startsWith("application/json")) { return Object.assign(Object.assign({}, json), (json.body && typeof json.body === "string" ? { body: JSON.parse(json.body) } : {})); } return json; } } exports.default = JSONSerializer; //# sourceMappingURL=json.js.map