可视化对比两个 JSON 的差异,高亮新增、删除和修改
null';if(a===undefined)return'undefined';if(typeof a==='object')return''+escHtml(JSON['stringify'](a))+'';if(typeof a==='string')return'\x22'+escHtml(a)+'\x22';return''+escHtml(String(a))+'';}function escHtml(a){return String(a)['replace'](/&/g,'&')['replace'](//g,'>');}function swapJson(){var a=document['getElementById']('jsonLeft'),b=document['getElementById']('jsonRight'),c=a['value'];a['value']=b['value'],b['value']=c;}function formatBoth(){try{var a=JSON['parse'](document['getElementById']('jsonLeft')['value']);document['getElementById']('jsonLeft')['value']=JSON['stringify'](a,null,0x2);}catch(c){}try{var b=JSON['parse'](document['getElementById']('jsonRight')['value']);document['getElementById']('jsonRight')['value']=JSON['stringify'](b,null,0x2);}catch(d){}}function clearAll(){document['getElementById']('jsonLeft')['value']='',document['getElementById']('jsonRight')['value']='',document['getElementById']('diffView')['innerHTML']='点击「对比差异」查看结果',document['getElementById']('summary')['style']['display']='none';}function loadExample(){document['getElementById']('jsonLeft')['value']=JSON['stringify']({'name':'张三','age':0x19,'city':'北京','skills':['JavaScript','React','Node.js'],'address':{'street':'长安街','zip':'100000'},'active':!![]},null,0x2),document['getElementById']('jsonRight')['value']=JSON['stringify']({'name':'张三','age':0x1a,'city':'上海','skills':['JavaScript','React','Vue','TypeScript'],'address':{'street':'南京路','zip':'200000','country':'中国'},'email':'zhangsan@example.com','active':![]},null,0x2),compareDiff();}