Skip to content

Commit cf32483

Browse files
committed
fix: normalized bug
1 parent 1874cc6 commit cf32483

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/http/json/json.controller.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ export class JsonController {
3737
}
3838

3939
const normalizedData = data => {
40-
data = JSON.stringify(data)
41-
data = data
42-
.replace(/\#/g, '') // replace "#" operation arg
43-
.replace(/\[\]/g, '')
44-
45-
return JSON.parse(data)
40+
Object.keys(data).forEach(key => {
41+
const normalizedKey = key
42+
.replace(/\#/g, '') // replace "#" operation arg
43+
.replace(/\[\]/g, '')
44+
if (normalizedKey !== key) {
45+
const tmp = data[key]
46+
data[normalizedKey] = tmp
47+
delete data[key]
48+
if (typeof data[normalizedKey] === 'object') {
49+
normalizedData(data[normalizedKey])
50+
}
51+
} else {
52+
if (typeof data[key] === 'object') {
53+
normalizedData(data[key])
54+
}
55+
}
56+
})
57+
return data
4658
}
4759

4860
while (jobList.length) {

0 commit comments

Comments
 (0)