Counting all same path in a JSON

Hi All,

I am curios if someone was solving a following problem.
In JsonGrinder.jl, I need to store leafs of JSONs of the same type (same path) to the same continuous array, such that when I pass it to Neural Network, BLAS will work over continous block of memory. To do this efficiently, I need to compute the number of leafs with a same path first to pre-allocate the array. Does anyone knows, how to this efficiently? For example using some magic inside JSON3 parser?
For example

{ "a": [ {"b" = 1}, {"b" = 2, c = 1}]}

will have 2 times path "a":"b" and once "a","c"

Thanks for the answer in advance.
Tomas