From 77f7281ff7cee541aaa51339512e6443b7d89e42 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期二, 05 一月 2021 12:04:25 +0800
Subject: [PATCH] 修改eslint配置增加mock配置
---
src/utils/JsonUtils.js | 74 ++++++++++++++++++------------------
1 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/src/utils/JsonUtils.js b/src/utils/JsonUtils.js
index d0cfef2..d4e6267 100644
--- a/src/utils/JsonUtils.js
+++ b/src/utils/JsonUtils.js
@@ -3,46 +3,46 @@
* @param {Object} type锛� 榛樿涓嶄紶 ==>鍏ㄩ儴灏忓啓;浼�1 ==>鍏ㄩ儴澶у啓;浼�2 ==>棣栧瓧姣嶅ぇ鍐�
* 灏唈son鐨刱ey鍊艰繘琛屽ぇ灏忓啓杞崲
*/
-function jsonKeysToCase(json, type) {
- if (typeof json === 'object') {
- var tempJson = JSON.parse(JSON.stringify(json))
- toCase(tempJson)
- return tempJson
- } else {
- return json
- }
+function jsonKeysToCase (json, type) {
+ if (typeof json === 'object') {
+ var tempJson = JSON.parse(JSON.stringify(json))
+ toCase(tempJson)
+ return tempJson
+ } else {
+ return json
+ }
- function toCase(json) {
- if (typeof json === 'object') {
- if (Array.isArray(json)) {
- json.forEach(function(item) {
- toCase(item)
- })
- } else {
- for (var key in json) {
- var item = json[key]
- if (typeof item === 'object') {
- toCase(item)
- }
- delete (json[key])
- switch (type) {
- case 1:
- // key鍊煎叏閮ㄥぇ鍐�
- json[key.toLocaleUpperCase()] = item
- break
- case 2:
- // key鍊奸瀛楁瘝澶у啓锛屽叾浣欏皬鍐�
- json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item
- break
- default:
- // 榛樿key鍊煎叏閮ㄥ皬鍐�
- json[key.toLocaleLowerCase()] = item
- break
- }
- }
- }
+ function toCase (json) {
+ if (typeof json === 'object') {
+ if (Array.isArray(json)) {
+ json.forEach(function (item) {
+ toCase(item)
+ })
+ } else {
+ for (var key in json) {
+ var item = json[key]
+ if (typeof item === 'object') {
+ toCase(item)
+ }
+ delete (json[key])
+ switch (type) {
+ case 1:
+ // key鍊煎叏閮ㄥぇ鍐�
+ json[key.toLocaleUpperCase()] = item
+ break
+ case 2:
+ // key鍊奸瀛楁瘝澶у啓锛屽叾浣欏皬鍐�
+ json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item
+ break
+ default:
+ // 榛樿key鍊煎叏閮ㄥ皬鍐�
+ json[key.toLocaleLowerCase()] = item
+ break
+ }
}
+ }
}
+ }
}
export default jsonKeysToCase
--
Gitblit v1.8.0