Ai
2 Star 0 Fork 0

mirrors_mapbox/jsonlint-check

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 664 Bytes
一键复制 编辑 原始数据 按行查看 历史
module.exports = function(json, space, newline, print) {
space = space || 2;
var expected = JSON.stringify(JSON.parse(json), null, space);
if (newline) expected += '\n';
if (print && expected !== json) {
var jLines = json.split('\n');
var eLines = expected.split('\n');
for (var i=0; i<jLines.length && i<eLines.length; i++) {
if (jLines[i] !== eLines[i]) {
console.log('expected', i+':', eLines[i]);
console.log('provided', i+':', jLines[i]);
return false;
}
}
console.log('missing new line');
return false;
}
else {
return expected === json;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_mapbox/jsonlint-check.git
git@gitee.com:mirrors_mapbox/jsonlint-check.git
mirrors_mapbox
jsonlint-check
jsonlint-check
master

搜索帮助