GJSON Parsing Question [SOLVED]


I am making heavy use of the fabulous gjson package which is taking a lot of pain away from working with Json in Go.
I’ve run up against an interesting problem though and would appreciate any thoughts or assistance with it.

I have a chunk of json:

   "took": 31,
   "timed_out": false,
   "_shards": {
      "total": 70,
      "successful": 70,
      "failed": 0
   "hits": {
      "total": 3709706,
      "max_score": 0,
      "hits": []
   "facets": {
      "1": {
         "_type": "date_histogram",
         "entries": [
               "time": 1502874000000,
               "count": 10,
               "min": 0.893,
               "max": 1.758,
               "total": 13.5977,
               "total_count": 10,
               "mean": 1.35977

and I am trying to extract the “mean” value of 1.35977. With straight jsonpath, its a walk in the park using:


But I’m not able to use that in gjson. I’ve been using the test playground here:


Which is hugely helpful… but so far no pattern I’ve tried has helped. Would appreciate any assistance.


As per usual, fight with it for hours then post here and bang… you stumble on the answer 5 mins later:


does the trick…

thanks anyway

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.