ohler55 / ojg

Optimized JSON for Go
MIT License
839 stars 50 forks source link

Aggregates #88

Closed dcmoura closed 1 year ago

dcmoura commented 2 years ago

Hey! Are you able to calculate aggregates with ojg? If so, could you please provide an example of an average of a field (using the command-line tool if possible)? Thanks!

ohler55 commented 2 years ago

There are no tools for performing an average over collected values without writing code. The code would be pretty simple but it would require a loop that does the summation.

An analytics package for OjG might be a nice addition though. Maybe with functions for average, max, min, unique, sum, and more. If you are interested in that and would like to see it added to OjG how about starting a discussion and we can starting putting together the functions for the package.

dcmoura commented 2 years ago

Here they support functions: https://github.com/json-path/JsonPath

ohler55 commented 2 years ago

I might use a different syntax than those function extensions to JSONPath but implementing something similar seems like a nice addition..

ohler55 commented 2 years ago

I added a discussion for this at #89. Lets use that for continuing the discussion.

ohler55 commented 1 year ago

This is really out of scope for the package and would be better implemented as a separate package.