Skip to content

Latest commit

 

History

History
78 lines (54 loc) · 1.52 KB

File metadata and controls

78 lines (54 loc) · 1.52 KB

Generate html-table from nested JSON-Object 📃




The way to be used:


1. let myJSON = { ... };
2. let myDOMContainer = document.getElementById("myDOMContainer");
3. JSON2Table.init(myJSON, myDOMContainer);




This is what it look like:

INPUT:

input

OUTPUT:

output

NOTE THIS KNOWN WEAKNESS:


There is a known issue with this script that I couldn't fix yet.
All properties in the JSON must have a unique name,
or the properties with the same name, must be in exactly the same nested order.

If there are two or more properties with the same name and different nested order
the script fails to place them to the right position.

Example:
// This fails, due to the different nested depth of properties with same name
{
    "myProp1": {
        ,"samePropertyName": {
            "prop1": 1
        }
        ,"notWorking": {
            "samePropertyName": {
                "prop1": 1
            }
        }
    }
}
// This still works, due to the same nested depth
{
    "myProp1": {
        ,"workingOne": {
            ,"samePropertyName": {
                "prop1": 1
            }
        }
        ,"workingTwo": {
            "samePropertyName": {
                "prop1": 1
            }
        }
    }
}