Hola muy buenos días a todos, espero estén bien, es que tengo el siguiente JSON
'product': [
{
"Line_Type": "12345",
"Plan": "TRIO",
"Product": "TELEFONICA",
"Product_Type": "Secundario",
"Service": "00009",
"State": "ACTIVO",
"Technology": "NN"
},
{
"Line_Type": "123456",
"Plan": "TRIO",
"Product": "INTERNET",
"Product_Type": "Primario",
"Service": "000091",
"State": "ACTIVO",
"Technology": "NN"
}, {
"Line_Type": "123457",
"Plan": "TRIO",
"Product": "CABLE",
"Product_Type": "Primario",
"Service": "0000912",
"State": "ACTIVO",
"Technology": "NN"
},
]
Y estoy buscando recorrer ese array en una función para que solo busque por "Product_Type"
y si es == a "Primario"
me devuelva el valor de "Product"
de ese objeto.
Estoy haciendolo de la siguiente forma
var data = 'product': [
{
"Line_Type": "12345",
"Plan": "TRIO",
"Product": "TELEFONICA",
"Product_Type": "Secundario",
"Service": "00009",
"State": "ACTIVO",
"Technology": "NN"
},
{
"Line_Type": "123456",
"Plan": "TRIO",
"Product": "INTERNET",
"Product_Type": "Primario",
"Service": "000091",
"State": "ACTIVO",
"Technology": "NN"
}, {
"Line_Type": "123457",
"Plan": "TRIO",
"Product": "CABLE",
"Product_Type": "Primario",
"Service": "0000912",
"State": "ACTIVO",
"Technology": "NN"
},
]
function Buscador(){
switch (data){
case ('Product_Type' == "Primario") :
return data.product[0].Product || null
break;
}
};
Pero no estoy recibiendo nada :/, agradecería un poco de ayuda