合并JSON文件
2021-03-31 04:26
标签:col init eof doc title pre htm rip char 下面是一段简单地代码 用来减少工作量合并代码 合并JSON文件 标签:col init eof doc title pre htm rip char 原文地址:https://www.cnblogs.com/sugartang/p/12101193.htmlDOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
meta name="viewport" content="width=device-width, initial-scale=1.0">
meta http-equiv="X-UA-Compatible" content="ie=edge">
title>Documenttitle>
head>
body>
script>
let BIG = {};let SM = {};
let BIGObj = JSON.parse(JSON.stringify(BIG))
let SMObj = JSON.parse(JSON.stringify(SM))
for(var key in SMObj) {
if(!BIGObj[key]){
BIGObj[key] = SMObj[key]
}
if(SMObj[key] instanceof Object){
for(var a in SMObj[key]){
if(!BIGObj[key][a]){
BIGObj[key][a] = SMObj[key][a]
}
}
}
}
console.log(JSON.stringify(BIGObj))
script>
body>
html>