Skip to main content
edited title
Link
Gilles Quénot
  • 36.8k
  • 7
  • 76
  • 97

Sum up the entries afrom json and save it in a variable

Source Link
ph3ro
  • 378
  • 2
  • 6
  • 18

Sum up the entries a json and save it in a variable

I have the below json file

[
    {
        "n_id": 1,
        "n_key": "sdfvnifughsdfvnsdfvnsd",
        "entries": 7
    },
    {
        "n_id": 2,
        "n_key": "amfgjbongmikjmjegieojgem",
        "entries": 8
    },
    {
        "n_id": 3,
        "n_key": "fdsggjhndsjfsjinfjghbdpojgd",
        "entries": 10
    }
]

How can I sum up all the entries in the above json file and save it in a variable JSON_SUM ??

I have zero knowledge in working with a json file, can someone please help me. I want to use this in a bash script