I have a JSON array.
"user": {
"value": [
{
"customerNo": "1234"
},
{
"customerNo": "abcd"
},
{
"customerNo": "1234"
}
]
}
To find the total number of unique customers in the JSON array using TypeScript, you can do the following:
const uniqueCustomers = Array.from(new Set(json.user.value.map(item => item.customerNo))).length;
console.log(uniqueCustomers);
The output would be 2, as duplicate customer numbers are ignored.