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
  • 165 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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

todd_davis
Influencer
Forum|alt.badge.img+23
  • Influencer
  • 313 replies
  • 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
  • 4 replies
  • 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