Skip to main content
Solved

When running JSON Fragmenter, can I capture the last JSON Index from each row into its own attribute value for every row after the fragment is done?

  • December 11, 2021
  • 2 replies
  • 127 views

I'm running JSON Fragmenter to break out an array, and, in the process, it indexes each row of that ID. Is there a way to retroactively put the last JSON Index value of each ID's array into every row associated with that ID? I'm trying to calculate a percentage of where each row is compared to its total. (JSON index [8] of ID XXXX is in the first 2.34% of ID XXXX's total JSON Index.)

 

Thanks, in advance!

Best answer by todd_davis

So the way I am interpreting what you have written is that you have split the json array into separate features and they hold the json index value.

 

You just need to do is put the records through a StatisticsCalculator, with a group by of the "ID" and then a stat of the max. But you may need to "add 1" to each json_index because it will start at 0, rather than 1.

 

An example is attached, but I have not added the 1 to the json index in it.

 

Cheers,

Todd

View original
Did this help you find an answer to your question?

2 replies

todd_davis
Influencer
Forum|alt.badge.img+22
  • Influencer
  • Best Answer
  • December 12, 2021

So the way I am interpreting what you have written is that you have split the json array into separate features and they hold the json index value.

 

You just need to do is put the records through a StatisticsCalculator, with a group by of the "ID" and then a stat of the max. But you may need to "add 1" to each json_index because it will start at 0, rather than 1.

 

An example is attached, but I have not added the 1 to the json index in it.

 

Cheers,

Todd


  • Author
  • December 12, 2021

Thanks, Todd!

 

I also ran across this post, where Takashi queried the JSON Count prior to splitting the array.

 

https://community.safe.com/s/question/0D54Q000080hL8C/count-elements-in-json-array

 

Thanks, again.

 

Ryan


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings