Results 1 to 3 of 3

Thread: [VB6] JNode - JSON revisited

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    [VB6] JNode - JSON revisited

    JNode is a "little brother" or alternative to my JsonBag.

    This take on the subject is a kind of stripped down minimal implementation of a VB6 JSON handling Class. Don't read anything into the name (the "node" part is just a node, as in a node in a tree of objects).

    JNode 1.0 weighs in at less than half the size of JsonBag 2.4 in source code terms. The main difference is that JNode makes no attempt to use any API calls or pointer operations to try to gain performance: everything is straight-up VB6 code. While this may reduce performance a bit most client-side real world JSON applications just aren't performance-critical anyway. In testing it seems plenty fast enough for most uses.


    Requirements

    Written as VB6 code, so you'd need VB6. But it is pretty "clean" VB6 so it may import right in and work in any VBA6 or later host, even 64-bit ones. Might work without changes in VB5 too, though I haven't looked at that.

    A version of Windows that can run VB6 programs and has or can support Microsoft's Scripting Runtime - since JNode uses Dictionary objects.


    Remarks

    I had originally left out serializing adding white space. I decided to add that in though because a big hunk of JSON without it can be frustrating to read through when you are debugging.

    This is not a drop-in replacement for JsonBag, but it should be reasonably close and usable as a replacement in many applications without a lot of trouble.

    I haven't created any fancy documentation for JNode, which I have found almost nobody has been reading anyway. Perhaps the code in the test cases included in the demo Project is enough. I might address this later though.

    I miss a few things, for example the CloneItem property in JsonBag. But not enough to bloat JNode by adding such a thing into it. Most of the things I use it for can by done simply by creating a new JNode and assigning its JSON property to the JSON property of the JNode I want to clone. Slow perhaps, but not that slow and good enough for most purposes anyway.
    Last edited by dilettante; Oct 15th, 2015 at 05:47 PM. Reason: removed bad version's attachment

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Unhappy Re: [VB6] JNode - JSON revisited

    I'll call this version 1.1, which corrects problems so serious that version 1.0 should not be used. I am removing 1.0 to prevent any further problems for people. Version 1.1 finishes the job of escaping control characters in JSON string values, and fixes the completely incorrect escaping of quote characters (") in the 1.0 version.

    These are really bad mistakes, and I can't figure out how I got that broken version uplaoded instead of one that works correctly. But I can only apologize to anyone who tried to use it and got into trouble.

    I only found it myself by actually downloading what I had uploaded here and retesting that with the larger suite of samples I've put together. Good thing I did! I'm also testing the JSON output generated by this code against the JSONLint page these days. [Of course if you test the wrong code it is hard to find your bugs!]

    Please replace any JNode 1.0 downloads with this one and discard them.


    Edited:

    This is really getting embarassing. The quote escaping was previously correct, so I've reverted that back. This should be considered the real version 1.1 now - the other one was junk.
    Attached Files Attached Files
    Last edited by dilettante; Oct 15th, 2015 at 07:49 PM.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] JNode - JSON revisited

    New version that corrects the parsing of JSON text that contains empty "array" or "object" items.
    Attached Files Attached Files

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