Number of Dictionary Entries

Is there a function that returns the number of items in a dictionary?

Thank you.

I can't find an obvious way, but this will work:


In this example, the result is in Local_NumberOfKeys

Here's the text from the first action:


Note the use of the "Pretty" version of the token. It's required, or you won't get the correct count.

Click for Explanation

Consider this dictionary:


If you convert it to JSON using the %JSONFromDictionaryPretty% token, you get this:

  "Key1": "Value1",
  "Key2": "Value2",
  "Key3": "Value3",
  "key4": "vau4",
  "key5": "value5\nvalue 5 second line"

So you can use the Filter Variable action ("Filter Text", actually) to count the number of lines in the JSON string:


Using the above example, that gives us a count of 7, which includes the opening and closing curly braces.

So just subtract 2 from the count, and you're good to go.


Thanks so much!

1 Like