Home > Blockchain >  JSON data structures
JSON data structures

Time:07-18

From my understanding, linear data structures are simple lists [] and dictionaries {}. Is the following data-structure a tree?

{
    "sex": "Male",
    "name": ["Dennis", "Mulenga", "Wibo"],
    "location": "Lusaka",
    "age": 35,
    "nrc": "1234567/2/3",
    "education": [{
        "Institution": "Wichita High",
        "start": 2010,
        "end": 2016
    }, {
        "Institution": "London Primary",
        "start": 2008,
        "end": 2010
    }, {
        "Institution": "St Faiths Kindergarten",
        "start": 2006,
        "end": 2008
    }],
    "work": [{
            "Employer": "ABC Widgets",
            "start": 2016,
            "end": 2020
        },
        {
            "Institution": "123 Consultants",
            "start": 2020,
            "end": null
        }
    ]
}

Stackoverflow is complaining because there is too much code in my question so here is some padding filler. I am a fish.

CodePudding user response:

It depends on your definition of a tree.

Inner objects, something recursive, an object that contains other objects (or array of objects). Heterogeneous tree in some sense.

A classic tree is primarily homogeneous, with a root, sub-trees, and leaves. Extra data has one type. JSON is a bit messy from this point of view.

  • Related