Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug #15

Open
wjllz opened this issue Oct 27, 2022 · 2 comments
Open

bug #15

wjllz opened this issue Oct 27, 2022 · 2 comments

Comments

@wjllz
Copy link

wjllz commented Oct 27, 2022

hey, this seems can't convert this json rightly:

{"formed": [
	0,
	1,
	2,
	3,
	4,
	5,
	6
]}
@wjllz
Copy link
Author

wjllz commented Oct 27, 2022

mini_patch, maybe buggy.... but it works... but I believe it should be buggy code....

  var rows = this.data.map(function (obj, index) {
    var tr = DOMHelper.createElement('tr')
    var firstTd = DOMHelper.createElement('td', typeof index);

    firstTd.appendChild(new JSONGrid(index).generateDOM());
    tr.appendChild(firstTd);
   
    // [+] add by 18f
    if(typeof obj != 'object'){
        var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
        td.appendChild(new JSONGrid(obj).generateDOM());
        tr.appendChild(td);
    }
   // [+] end patch

    keys.forEach(function (key, keyIdx) {
      var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
      var value = (obj[key] === undefined || obj[key] === null)
        ? '' + obj[key]
        : obj[key]
        ;
      td.appendChild(new JSONGrid(value).generateDOM());
      tr.appendChild(td);
    });

    return tr;
  });

@wjllz
Copy link
Author

wjllz commented Oct 27, 2022

The patch code which I think is bug, it is because that:

I assume keys always be empty set when obj is not a object, but is it always true? If not, critical bug will happened :(

The original writer write this code:

When we call processArray, the element of the array always be a object, so it can't deal with [1, 2, 3, 4, 5]. in this way, keys will be empty set....

And I think there are another bug:

"date": ["111", "222", "333"],

use https://www.araujoigor.com/en/json-grid u will found the resolve result is wrong...

make my patch be this:

    // [+] add by 18f
    if(typeof obj != 'object'){
        var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
        td.appendChild(new JSONGrid(obj).generateDOM());
        tr.appendChild(td);
        return tr;
    }
   // [+] end patch

get this result:

image

Still wrong... but now it is easy read....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant