197
197
if (val[0] instanceof Object && (val[0] instanceof Array == false)) { // && JSONObject.isArrayKey(key, null, isRestful)) {
198
198
// alert('onRenderJSONItem key = ' + key + '; val = ' + JSON.stringify(val))
199
199
200
- var ckey = key.substring(0, key.lastIndexOf('[]'));
200
+ var ckey = key == null ? null : key .substring(0, key.lastIndexOf('[]'));
201
201
202
- var aliaIndex = ckey.indexOf(':');
202
+ var aliaIndex = ckey == null ? -1 : ckey .indexOf(':');
203
203
var objName = aliaIndex < 0 ? ckey : ckey.substring(0, aliaIndex);
204
204
205
- var firstIndex = objName.indexOf('-');
205
+ var firstIndex = objName == null ? -1 : objName .indexOf('-');
206
206
var firstKey = firstIndex < 0 ? objName : objName.substring(0, firstIndex);
207
207
208
208
for (var i = 0; i < val.length; i++) {
270
270
}
271
271
}
272
272
else if (val instanceof Object) {
273
- var aliaIndex = key.indexOf(':');
273
+ var aliaIndex = key == null ? -1 : key .indexOf(':');
274
274
var objName = aliaIndex < 0 ? key : key.substring(0, aliaIndex);
275
275
276
276
// var newVal = JSON.parse(JSON.stringify(val))
@@ -1519,16 +1519,118 @@ https://github.com/Tencent/APIJSON/issues
1519
1519
} catch (ex) {
1520
1520
log(ex)
1521
1521
}
1522
+
1523
+ var path = null;
1524
+ var key = null;
1525
+ var thiz = {
1526
+ _$_path_$_: null,
1527
+ _$_table_$_: null
1528
+ };
1529
+
1522
1530
if (isSingle || ret instanceof Array || (ret instanceof Object == false)) {
1523
- this.jsonhtml = ret
1531
+ var val = ret;
1532
+ if (isSingle != true && val instanceof Array && val[0] instanceof Object && (val[0] instanceof Array == false)) {
1533
+ // alert('onRenderJSONItem key = ' + key + '; val = ' + JSON.stringify(val))
1534
+ var ckey = key == null ? null : key.substring(0, key.lastIndexOf('[]'));
1535
+
1536
+ var aliaIndex = ckey == null ? -1 : ckey.indexOf(':');
1537
+ var objName = aliaIndex < 0 ? ckey : ckey.substring(0, aliaIndex);
1538
+
1539
+ var firstIndex = objName == null ? -1 : objName.indexOf('-');
1540
+ var firstKey = firstIndex < 0 ? objName : objName.substring(0, firstIndex);
1541
+
1542
+ for (var i = 0; i < val.length; i++) {
1543
+ var vi = val[i]
1544
+
1545
+ if (vi instanceof Object && vi instanceof Array == false && JSONObject.isTableKey(firstKey, val, isRestful)) {
1546
+ // var newVal = JSON.parse(JSON.stringify(val[i]))
1547
+ if (vi == null) {
1548
+ continue
1549
+ }
1550
+
1551
+ var curPath = '' + i;
1552
+ var curTable = firstKey;
1553
+ var thiz = {
1554
+ _$_path_$_: curPath,
1555
+ _$_table_$_: curTable
1556
+ };
1557
+
1558
+ var newVal = {};
1559
+ for (var k in vi) {
1560
+ newVal[k] = vi[k]; //提升性能
1561
+ if (this.isFullAssert) {
1562
+ try {
1563
+ var tr = this.currentRemoteItem.TestRecord || {};
1564
+ var d = this.currentRemoteItem.Document || {};
1565
+ var standard = this.isMLEnabled ? tr.standard : tr.response;
1566
+ var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
1567
+ var tests = this.tests[String(this.currentAccountIndex)] || {};
1568
+ var responseObj = (tests[d.id] || {})[0]
1569
+
1570
+ var pathUri = (StringUtil.isEmpty(curPath, false) ? '' : curPath + '/') + k;
1571
+ var pathKeys = StringUtil.split(pathUri, '/');
1572
+ var target = this.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
1573
+ var real = JSONResponse.getValByPath(responseObj, pathKeys);
1574
+ var cmp = this.isMLEnabled ? JSONResponse.compareWithStandard(target, real, pathUri) : JSONResponse.compareWithBefore(target, real, pathUri);
1575
+ cmp.path = pathUri;
1576
+ var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
1577
+ thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
1578
+ var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
1579
+ thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
1580
+ } catch (e) {
1581
+ thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
1582
+ var countKey = '_$_redCount_$_';
1583
+ thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
1584
+ }
1585
+ }
1586
+
1587
+ delete vi[k]
1588
+ }
1589
+
1590
+ vi._$_this_$_ = JSON.stringify(thiz)
1591
+ for (var k in newVal) {
1592
+ vi[k] = newVal[k]
1593
+ }
1594
+ }
1595
+
1596
+ }
1597
+ }
1598
+
1599
+ this.jsonhtml = val;
1524
1600
}
1525
1601
else {
1526
- this.jsonhtml = Object.assign({
1527
- _$_this_$_: JSON.stringify({
1528
- _$_path_$_: null,
1529
- _$_table_$_: null
1530
- })
1531
- }, ret)
1602
+ for (var k in ret) {
1603
+ if (this.isFullAssert) {
1604
+ try {
1605
+ var tr = this.currentRemoteItem.TestRecord || {};
1606
+ var d = this.currentRemoteItem.Document || {};
1607
+ var standard = this.isMLEnabled ? tr.standard : tr.response;
1608
+ var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
1609
+ var tests = this.tests[String(this.currentAccountIndex)] || {};
1610
+ var responseObj = (tests[d.id] || {})[0]
1611
+
1612
+ var pathUri = k;
1613
+ var pathKeys = StringUtil.split(pathUri, '/');
1614
+ var target = this.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
1615
+ var real = JSONResponse.getValByPath(responseObj, pathKeys);
1616
+ // c = JSONResponse.compareWithBefore(target, real, path);
1617
+ var cmp = this.isMLEnabled ? JSONResponse.compareWithStandard(target, real, pathUri) : JSONResponse.compareWithBefore(target, real, pathUri);
1618
+ cmp.path = pathUri;
1619
+ var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
1620
+ thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
1621
+ var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
1622
+ thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
1623
+ } catch (e) {
1624
+ thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
1625
+ var countKey = '_$_redCount_$_';
1626
+ thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
1627
+ }
1628
+ }
1629
+ }
1630
+
1631
+ this.jsonhtml = Object.assign({
1632
+ _$_this_$_: JSON.stringify(thiz)
1633
+ }, ret)
1532
1634
}
1533
1635
1534
1636
}
@@ -1844,7 +1946,7 @@ https://github.com/Tencent/APIJSON/issues
1844
1946
var name = item == null ? '' : StringUtil.get(item.name);
1845
1947
target.value = text = before + name + after
1846
1948
if (target == vScript) { // 不这样会自动回滚
1847
- App .scripts[App .scriptType][App .scriptBelongId][App .isPreScript ? 'pre' : 'post'].script = text
1949
+ this .scripts[this .scriptType][this .scriptBelongId][this .isPreScript ? 'pre' : 'post'].script = text
1848
1950
}
1849
1951
else if (target == vInput) {
1850
1952
inputted = target.value;
@@ -1870,7 +1972,7 @@ https://github.com/Tencent/APIJSON/issues
1870
1972
}
1871
1973
1872
1974
if (isInputValue != true) {
1873
- App .showOptions(target, text, before + name + (isSingle ? "'" : '"') + ': ', after.substring(3), true);
1975
+ this .showOptions(target, text, before + name + (isSingle ? "'" : '"') + ': ', after.substring(3), true);
1874
1976
}
1875
1977
} else {
1876
1978
target.selectionStart = selectionStart;
0 commit comments