I want to parse this JSON array and print the salary so this what I have tried so far
there is nothing logged in the Console
if (data.action == 'SendArray') {
let invites = data.invites
const obj = JSON.parse(invites)
const myJSON = JSON.stringify(obj);
console.log(myJSON.salary)
}
JSON:
{"factioname":"sp-force","inviter":"MohammedZr","salary":5000},
{"factioname":"air-force", "inviter":"Admin","salary":8000}
myJSON.salarymake no sense (strings don't have a.salaryproperty), or it's literally just a normal, plain, "boring" object. And on a JS note: never use==, always use===unless your conditional only works because type coercion.jsonfiles. It works on objects. You Should logobj.salary.json = [{"factioname":"sp-force","inviter":"MohammedZr","salary":5000}, {"factioname":"air-force", "inviter":"Admin","salary":8000}] for ({salary} of json) console.log(salary)