Using COUNT with top level JSONPath

I'm trying to use the COUNT function with a top level JSON path, like so:


I know that my variable contains valid JSON because I'm referencing values with %JSONValue% in other parts of the macro successfully.

Is there a way to COUNT just the top level array?

My JSON object looks something like

[
  {object},
  {object},
  {object}
]

Normally I would use javascript to pull this off, but I'm running into the "Variable “KMVAR_InstanceBasecampTodosRaw” excluded from environment to ensure the environment is not too large" error because it's so huge.

If there is another means to do this I'm open to doing that also.

using %JSONValue%Var[0]% can get the count of JSON objects. Is this what you want?

2 Likes
[
  {object},
  {object},
  {object}
]

If that means that %JSONValue%InstanceBasecampTodosRaw[0]% would return 3, then yes :slight_smile:.

Verified this worked for me.

I have the same problem. In fact, it seems several functions can't work with JSON path, COUNT() or even JSONVALUE(). Like Broskees' situation, the text turned into red, even the text token %JSONValue% worked well.

Screenshot 2021-04-24 at 20.36.25