Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1469

Load Json data to Treeview by ScriptControl Activex With vb6

$
0
0
Advantages: The JSON parsing method is completely self-implemented, which is more assured. It took 3 days to write, the main gain is to learn various data types of JSON data, insert, add, modify and other technologies.
It just uses Microsoft's script object. If you use third-party JSON objects and classes, it may cause parsing errors.
Using ie’s javascript object, as well as Google v8 js, it is highly accurate.
Disadvantages: It may be slower and requires a deeper grasp of JS technology.

Code:

function GetKeysArr(jsonObj) {
    var length = 0;
    var data = [];
    for (var Item in jsonObj) {
        length++;
        if (Object.prototype.toString.call(jsonObj) === '[object Array]') {
            data.push('$Arr(' + length + ')')
        } else {
            if (Object.prototype.toString.call(jsonObj[Item]) === '[object Array]') {
                data.push('【ArrayObj】' + Item)
            } else {
                data.push(Item)
            }
        };
    }
    return data;
}
function GetValuesArr(jsonObj) {
    var length = 0;
    var data = [];
    for (var Item in jsonObj) {
        data.push(jsonObj[Item]);
        length++
    }
    return data;
}
var JsonObj = {
    "444": "s4",
    "a1": 33,
    ",strddd": "ss",
    "idlist": [11, 33],
    "A2": "strtest",
    "A3": "strtest2",
    "a4": ["v1", "v2", {
        "a41": 41,
        "a42": 42
    }],
    "ChildObjA": {
        "c1": 11,
        "c2": 22
    }
};

Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 1469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>