ArduinoJSON - manually calculate size for buffer? Create my own assistant tool?

Good day, ArduinoJSON users.

I'm looking to build a similar tool as the Assistant that is offered on the arduinoJSON website. I'm working on a project that will offer a JSON builder tool that is catered to add key and values that my project uses and spew out the final JSON file. So as per the docs, in order to read the json file, I need to create a buffer that is the exact size that i'm trying to load and then some.

So it appears that the tool generates bulk code using two functions:


If I put together a little HTML + JS based JSON building tool of my own, oriented for my own project, how would I then calculate my own buffer size for the json files? The documentation says that the assistant tool uses generates two functions JSON_OBJECT_SIZE(0) + JSON_OBJECT_SIZE(1) and if your objects contain sub json objects or arrays of objects, it will look this:


my question is - If I'm writing my own tool, can I not just look through the entire JSON file, count how many objects, keys, arrays entries there are the json file and simply generate something like


Or does having that above mentioned repeating use of JSON_OBJECT_SIZE and JSON_ARRAY_SIZE have any sort of significance? If I could just boil it down to an integer value too, I could do with that as well. What do those two functions return anyways? They get totaled into an integer to I suppose they return the buffer cost of # number of arrays and objects?