sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
288 stars 60 forks source link

stdJSON issues + improvement suggestions #93

Closed thefasquelle closed 6 months ago

thefasquelle commented 6 months ago

Hello, looking for a JSON module to handle JSON config files, I tested your stdJSON class. The first thing i did was trying the example at the top of the file, with just one additional line to write to a file. It didn't work, so I digged into the code and added Option Explicit. Then VBE and rubberduck pointed the following issues :

Also the example snippet is not functional because of the .obj and .toVBON() methods are not implemented (I suppose toVBON is actually ToVBObject ?)

And lastly, the pretty indent function seems broken, here is the result I got from the example snippet:

{
  "key":  {
    "a":1,
    "b":"hello",
    "val":        [
                                                [
                                                1,
                                                "hello",
                                                "shit"
                                    ]

        ]

  }

}

This leave me wondering: is it safe for me to use this class ? Has it been thoroughly tested ? The ToFile() method at least has not. I wanted to use this class because its API is pretty nice and the code is not too big but these issues show a lack of testing.

sancarn commented 6 months ago

Hi there,

Thanks for logging the issues. The pretty print issue is something I had ran into too, but had totally forgot about. These issues are now fixed in the latest version.

This leave me wondering: is it safe for me to use this class? Has it been thoroughly tested?

Depends what you mean. We've been using this in a number of our business projects, but the reality is we have only tested the things we use regularly - parsing, creation and non-pretty stringification - which are really the only 3 things which are mission critical also. Pretty printing was always added as a nice-to-have for debugging purposes.

I have not exhaustively tested everything, if you want to add unit tests, happy to accept a PR.

It should be noted that at present tests are ran infrequently as is. That said, compare this to your average VBA project... It's generally rare VBA projects are tested just because their are few testing tools, especially because they require the VBE.