dissect.cstruct_legacy icon indicating copy to clipboard operation
dissect.cstruct_legacy copied to clipboard

json support

Open Hadatko opened this issue 6 years ago • 1 comments

Would be nice to have chance to get output in json type. result.toJSON() => {'type':'struct', 'name':'structName','members':[{...},{...}]} or {'type':'struct', 'name':'structName','members':{'paam1':{...},'paam2':{...},...}}

Hadatko avatar Dec 19 '19 13:12 Hadatko

struct definition

struct B
{
    uint16_t a;
};
struct A
{
    struct B b[2];
};

B.a = 5
A.b=[5,5] //A.b[0].a=5;A.b[1].a=5;

json example for B:

{
    "B": {
        "a": {
            "type": "uint16",
            "value": 5
        }
    }
}

json example for A:

{
    "A": {
        "b": {
            "type": "B",
            "value": [{
                "a": {
                    "type": "uint16",
                    "value": 5
                }
            }, {
                "a": {
                    "type": "uint16",
                    "value": 5
                }
            }]
        }
    }
}

Hadatko avatar Dec 20 '19 08:12 Hadatko