Results 1 to 10 of 10

Thread: Load Json data to Treeview by ScriptControl Activex With vb6

  1. #1

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Load Json data to Treeview by ScriptControl Activex With vb6

    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 Images  
    Attached Files Attached Files
    Last edited by xiaoyao; May 8th, 2021 at 04:41 AM.

  2. #2
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    316

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Maybe you should use a StringBuilder to improve the readability of your code (more importantly, StringBuilder can greatly increase the processing speed of strings):

    StringBuilder - Fast string concatenation

    The following is an example of RC6.StringBuilder:

    Code:
        With New_c.StringBuilder
            .AddNL "'444': 's4' ,"
            .AddNL "'a1': 33 ,"
            .AddNL "'strddd': 'ss' ,"
            .AddNL "'idlist': [11,33] ,"
            .AddNL "'A2': 'strtest' ,"
            .AddNL "'A3': 'strtest2', "
            .AddNL "'a4': ["
            .AddNL "    'V1' ,"
            .AddNL "    'V2' ,"
            .AddNL "    {"
            .AddNL "        'a41':41,"
            .AddNL "        'a42':42,"
            .AddNL "    }"
            '...
            '...
            JsonStr = Replace(.ToString(), "'", """")
        End With

  3. #3

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    I find it easy to add data or modify it.
    But if you insert a new object somewhere in the middle of the object, or if you insert an item after an array of four elements or an item in the middle.It is also very difficult to use these basic functions well.

  4. #4
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    316

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Quote Originally Posted by xiaoyao View Post
    I find it easy to add data or modify it.
    But if you insert a new object somewhere in the middle of the object, or if you insert an item after an array of four elements or an item in the middle.It is also very difficult to use these basic functions well.
    The operations you mentioned can be easily implemented in RC6.Collection (New_c.JSONObject, New_c.JSONArray). You always seem to want to open an undersea tunnel with an axe instead of a shield machine.

    In my opinion, some of the technologies you are currently researching are meaningless.

  5. #5

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Quote Originally Posted by SearchingDataOnly View Post
    The operations you mentioned can be easily implemented in RC6.Collection (New_c.JSONObject, New_c.JSONArray). You always seem to want to open an undersea tunnel with an axe instead of a shield machine.

    In my opinion, some of the technologies you are currently researching are meaningless.
    If everyone thinks so, what kind of IDE similar to VB6 does he develop?Is it not better to use VfB directly, which has been developed for six years. Or use VB.NET, which has been around for more than two decades.

    Fortunately, what you said is just a few.
    Some time ago, people often attacked my posts.They think that some of the articles I publish are 100% meaningless and spam.


    This forum was originally just an exchange of technology, but now it has become an international war.In fact, all I want is to compare who is fast and who is slow. Of course, sometimes I just want to be able to have such a method, my speed is very slow, I do not matter.


    When I used to comment on the vb6 activex control,developed by others, you also had opinions.It is normal to comment on a product.


    But at least if you are his user, you at least you have learned to use or you have a better method, but also to provide source code for comparison basis.
    Last edited by xiaoyao; May 8th, 2021 at 11:25 AM.

  6. #6

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    At least in this case, it's just the simplest JS operation. When Microsoft said what Firefox browser you used, our XP IE6 was the first in the world. Finally, he became the most rubbish browser, the speed is very slow, often stuck. In the end, Microsoft divorced and he gave up his browser. It directly uses the Google core.

    So I still think that a lot of people don't go to the test at all, and they talk nonsense there again.
    You only have to test carefully, and then, after understanding my code, on the basis of my code, there is no way to give him appropriate improvement.

    Only when you understand it, you will understand that my code is really interesting, and there are many aspects of creativity.


    最起码在这个问题上,它只是最简单的js操作。想当年微软说你们用什么火狐浏览器呢,我们XP的IE6全世界第一。
    最后他成为最垃圾的浏览器,速度很慢,经常卡死。
    最后微软还离婚了,他也放弃了他自己的浏览器。直接采用了谷歌内核。

  7. #7

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    In fact, the most difficult is a lot of others to develop a good control, you are not more than half can understand the source code?

    Anyway, according to my understanding, more than 90% of people do not have the ability to modify other people's seemingly simple controls.

  8. #8

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Quote Originally Posted by SearchingDataOnly View Post
    Maybe you should use a StringBuilder to improve the readability of your code (more importantly, StringBuilder can greatly increase the processing speed of strings):

    StringBuilder - Fast string concatenation

    The following is an example of RC6.StringBuilder:

    Code:
        With New_c.StringBuilder
            .AddNL "'444': 's4' ,"
            .AddNL "'a1': 33 ,"
            .AddNL "'strddd': 'ss' ,"
            .AddNL "'idlist': [11,33] ,"
            .AddNL "'A2': 'strtest' ,"
            .AddNL "'A3': 'strtest2', "
            .AddNL "'a4': ["
            .AddNL "    'V1' ,"
            .AddNL "    'V2' ,"
            .AddNL "    {"
            .AddNL "        'a41':41,"
            .AddNL "        'a42':42,"
            .AddNL "    }"
            '...
            '...
            JsonStr = Replace(.ToString(), "'", """")
        End With
    Can you provide the Source code?
    In fact, I hope that as far as possible is not to use other people's third-party DLL.
    If you have the ability to develop, why do you have to use someone else's?
    You have to know that the United States is so overbearing that vaccines are completely insufficient now, and he actually prevents China from entering the WHO procurement list.
    Soviet American aviation has been developing for sixty years. They banned China from the space station from the beginning and now they're saying we want to see your space station.


    Vfb has long been developed. There are two wild mother-in-law's company, but they do not give up, but also where to collect money?
    Maybe it's just a joke, maybe he can really do a good job.

  9. #9

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Let's go back to technical communication. I now mainly use the asynchronous loading mechanism. When I open the software, only the first-level root data is loaded, maybe 5 items, 20 items, and there are tens of thousands of key names and data not loaded first.
    If it is a json object, similar to {'a':33,'b':44}, it does not provide the length attribute directly, and can only take the length of the array. Maybe the new version of Google V8 JS engine provides the algorithm of Json object length, and ie11 only started to support the JSON object length?

    Suppose there are 3 objects and 5 arrays in the first layer. Just want to get the amount of their subordinate data, will it take a lot of CPU parsing time? Just get the length of the array, it should take up almost no CPU time, right?
    In this regard, if there are multiple different JSON parsing components or functional modules, the performance of the function algorithm will be more different, such as CPU usage, memory usage, and computing time.
    Competition: Use JSON large files
    1. How much time does it take to parse the first-level key name and data
    2. How long does it take to get the quantity of the next layer?
    3. How long does it take to get the key name and data of the next layer?

    for(var Item in jsonObj2) {length++, I use this method, in theory, is to get all the key value names of his next level, right? Although I only want to get the length of how many items there are. jsonObj[Item], this is to get the data content of each item. This will take more time.
    In theory, the key value is as short as the file name, and the ItemValue is like the file content, which may be 30 bytes or 2KB.
    Last edited by xiaoyao; May 8th, 2021 at 12:25 PM.

  10. #10
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,473

    Re: Load Json data to Treeview by ScriptControl Activex With vb6

    Quote Originally Posted by xiaoyao View Post
    If it is a json object, similar to {'a':33,'b':44}, it does not provide the length attribute directly...
    Debug.Print New_c.JSONDecodeToCollection("{""a"":33,""b"":44}").Count

    Olaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width