# Counting all same path in a JSON

**URL:** <https://discourse.julialang.org/t/counting-all-same-path-in-a-json/75433>\
**Category:** Performance\
**Created:** [January 29, 2022, 8:50pm UTC](https://discourse.julialang.org/t/counting-all-same-path-in-a-json/75433 "2022-01-29T20:50:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [January 29, 2022, 8:50pm UTC](https://discourse.julialang.org/t/counting-all-same-path-in-a-json/75433/1 "2022-01-29T20:50:07Z")

</div>

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

```julia
{ "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
