Children shortcuts

As covered in How to access children, cJobect children are roughly equivalent to JavaScript objects’ children. However the syntax of VBA means that we have to be a little more verbose than JavaScript. To help a bit, here are some shortcuts for accessing property values.


This will return the value of the selected property

or, as we learned in How to access children, by childIndex

Similarly, this will convert it to to a string

or by childIndex

 

This is roughly equivalent to simply job.somekey or job[0]  and job.somekey.toString() or job[0].toString()


However you can pass the name of the child as an argument to toString() or to value() ( actually in the case of value() we have to use cValue() when passing a child name  (.. it’s a long story but it’s to do with limitations in VBA classes), so we can rewrite the .child() examples above as 


This will return the value of the selected property

and

Grandchildren

these methods take the same arguments as .child() , so these examples all work

is equivalent to

which is close to the JavaScript

You can also mix index and named keys, so

 

is equivalent to

 

and the JavaScript equivalent

Now let’s look at some more cJobject topics.

For more on this see How to use cJobject