JSFiddle - React, Tailwind, and code Playground
JavaScript
const jsonData = '{"cols":[{"label":"sprint_status","type":"string"},{"label":"count","type":"string"}],"rows":[{"c":[{"v":"NOT_COMPLETED"},{"v":4}]}]}';
const DataMap = {
COMPLETED: 'green',
NOT_COMPLETED: 'red',
};
let colors = [];
Object.keys(DataMap).forEach((key, index) => {
if (jsonData.search("\"" + key + "\"") !== -1) {
colors.push(DataMap[key]);
}
});
console.log(colors);