处理JSON.对象异常

This commit is contained in:
aixianling
2023-03-01 17:54:57 +08:00
parent 3e1991eaaa
commit ebcfff03cc

View File

@@ -25,7 +25,7 @@ const insert = ({table, form}) => {
if (form.id) {//编辑
let arr = Object.keys(form).filter(e => form[e]).map(e => {
if (typeof form[e] == "object") {
if (checkJson(form[e])) form[e] = JSON.stringify(form[e]).replace(/"/g, "\'")
if (checkJson(form[e])) form[e] = JSON.stringify(form[e]).replace(/"'/g, "\'")
else form[e] = JSON.stringify(form[e])
}
return `${e}='${form[e]}'`
@@ -37,7 +37,7 @@ const insert = ({table, form}) => {
if (form[e]) {
cols.push(e)
if (typeof form[e] == "object") {
if (checkJson(form[e])) form[e] = JSON.stringify(form[e]).replace(/"/g, "\'")
if (checkJson(form[e])) form[e] = JSON.stringify(form[e]).replace(/"'/g, "\'")
else form[e] = JSON.stringify(form[e])
}
arr.push(`'${form[e]}'`)