JSON has no relevant here.
I can’t give you the code you need to use because I don’t know what language you are working in, and then if I just give you the answer you won’t have learned anything. This is basic data manipulation in any language.
You code above doesn’t have enough code to answer that