"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.replaceKeys = replaceKeys;
exports["default"] = void 0;

var _lodash = require("lodash");

/**
 * 替换json的key值
 * @param {object} data json数据
 * @param {object} map 用value值替换key值，比如：{ children: 'categories' }
 */
function replaceKeys(data, map) {
  var dataString = JSON.stringify(data);
  (0, _lodash.forEach)(map, function (value, key) {
    dataString = dataString.replace(RegExp("\"".concat(key, "\":"), 'g'), "\"".concat(value, "\":"));
  });
  return JSON.parse(dataString);
}

var _default = {
  replaceKeys: replaceKeys
};
exports["default"] = _default;
//# sourceMappingURL=util.js.map
