JSON Path Tester

by Erik Bartlow

HTML

<input type="text" id="txtFound" value="No" />
<input type="button" id="btnFind" value="Find It" />

JavaScript

var model = {
    "id": "1",
        "Name": "Model 1",
        "Published": "false",
        "DateUpdated": Date(),
        "Owner": {
        "Name": "Erik Bartlow",
            "Email": "[email protected]"
    },
        "rows": [],
        "sections": []
};
model.rows = [{
    "id": "1",
        "Name": "Value Chain Relationship",
        "Type": "time",
        "Parent": "1",
        "Siblings": {
        "before": "0",
            "after": "2"
    },
        "rows": [],
        "elements": []
}, {
    "id": "2",
        "Name": "Business Process Area",
        "Type": "area",
        "Parent": "1",
        "Siblings": {
        "before": "1",
            "after": "3"
    },
        "rows": [],
        "elements": [{
        "id": "1",
            "Name": "Vision / Strategy",
            "Type": "base",
            "Parent": "2",
            "Siblings": {
            "before": "0",
                "after": "2"
        },
            "StartGroup": "true",
            "EndGroup": "false"
    }, {
        "id": "2",
            "Name": "Complete and Total Risk Management",
            "Type": "base",
            "Parent": "2",
            "Siblings": {
            "before": "1",
                "after": "0"
        },
            "StartGroup": "false",
            "EndGroup": "true"
    }]
}, {
    "id": "3",
        "Name": "Social &amp; Environmental Responsibile (SER)",
        "Type": "topic",
        "Parent": "1",
        "Siblings": {
        "before": "2",
            "after": "0"
    },
        "rows": [],
        "elements": [{
        "id": "3",
            "Name": "Ethics &amp; Compliance Strategy",
            "Type": "base",
            "Parent": "3",
            "Siblings": {
            "before": "0",
                "after": "0"
        },
            "StartGroup": "true",
            "EndGroup": "true"
    }]
}];

function getObjects(obj, oType, key, val) {
    var objects = [];
    
    objects = $.grep(obj, function(i, o){
        if (...