cJobject and javascript equivalents

There is plenty of reference information cJobject on this site, starting with How to use cJobject, or just enter cJobject in the search box. Here's a quick reminder of what you'll need to understand to follow this app example.

What is cJobject

It's an attempt to emulate a JavaScript object within the limits of VBA syntax. It's fully recursive, so you can have endless parents and children depth, can handle arrays, and knows how to Parse JSON, and how to create it. I use it in almost everything I do in VBA - The great thing for me is to be able to 'create classes on the fly' with dynamic properties, which is exactly what we need to be able to parameterize VBA applications.

Some examples

Here's how it looks against the equivalent JavaScript using a few common things you need to do. Since we are creating classes on the fly at run time, the syntax of VBA makes it a little more wordy, but it achieves approximately the same thing. There are a few useful things exposed also that don't exist in javaScript

what

vba

JavaScript

Create an object from a JSON string

set job = JSONParse(jsonString)

var job = JSON.parse(jsonString);

Create a JSON string from an object

JSONStringify (job) or job.stringify()

JSON.stringify(jsonString);

Create a new object (using Nothing as the argument makes this the root)

set job = new cJobject
job.init (Nothing)

var job = {};

Access the key of an object (for example the word 'name' of the object job.name)

s = job.key

n/a

Access the full key of an object (for example the word 'boss.name' of the object job.boss.name)