I have the following json object:
var json = {
"tpAmbiente":null,
"hotelPesquisa":[
{
"dtEntrada":"20170510",
"dtSaida":"20170511",
"hotel":{
"id":94,
"nome":"Itamarati"
},
"quarto":[
{
"quartoUh":[
{
"nQUarto": 1,
"tarifa":{
"vlDiariaTotal":157.21,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
{
"nQUarto": 2,
"tarifa":{
"vlDiariaTotal":157.21,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
]
}
]
},
{
"dtEntrada":"20170510",
"dtSaida":"20170511",
"hotel":{
"id":95,
"nome":"copacabana"
},
"quarto":[
{
"quartoUh":[
{
"nQUarto": 1,
"tarifa":{
"vlDiariaTotal":102.1,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
{
"nQUarto": 2,
"tarifa":{
"vlDiariaTotal":102.1,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
]
}
]
},
{
"dtEntrada":"20170510",
"dtSaida":"20170511",
"hotel":{
"id":96,
"nome":"Itamarati"
},
"quarto":[
{
"quartoUh":[
{
"nQUarto": 1,
"tarifa":{
"vlDiariaTotal":157.21,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
{
"nQUarto": 2,
"tarifa":{
"vlDiariaTotal":157.21,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
]
}
]
},
{
"dtEntrada":"20170510",
"dtSaida":"20170511",
"hotel":{
"id":96,
"nome":"Litoral Hotel"
},
"quarto":[
{
"quartoUh":[
{
"nQUarto": 1,
"tarifa":{
"vlDiariaTotal":1001.00,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
{
"nQUarto": 2,
"tarifa":{
"vlDiariaTotal":1001.00,
"desconto":null
},
"qtDisponivel":null,
"desconto":null
},
]
}
]
}
]
};
How do I filter this object so that I can only show hotels where the price is higher than 100 and less than 900?
Price is in:
hotelPesquisa[].quarto[].quartoUh[].tarifa.vlDiariaTotal
Return I need:
"hotelPesquisa":[ { "dtEntrada":"20170510", "dtSaida":"20170511", "hotel":{ "id":94, "nome":"Itamarati" }, "quarto":[ { "quartoUh":[ { "nQUarto": 1, "tarifa":{ "vlDiariaTotal":890.21, "desconto":null }, "qtDisponivel":null, "desconto":null }, { "nQUarto": 2, "tarifa":{ "vlDiariaTotal":890.21, "desconto":null }, "qtDisponivel":null, "desconto":null }, ] } ] }, { "dtEntrada":"20170510", "dtSaida":"20170511", "hotel":{ "id":95, "nome":"copacabana" }, "quarto":[ { "quartoUh":[ { "nQUarto": 1, "tarifa":{ "vlDiariaTotal":102.1, "desconto":null }, "qtDisponivel":null, "desconto":null }, { "nQUarto": 2, "tarifa":{ "vlDiariaTotal":102.1, "desconto":null }, "qtDisponivel":null, "desconto":null }, ] } ] }, { "dtEntrada":"20170510", "dtSaida":"20170511", "hotel":{ "id":96, "nome":"Itamarati" }, "quarto":[ { "quartoUh":[ { "nQUarto": 1, "tarifa":{ "vlDiariaTotal":890.21, "desconto":null }, "qtDisponivel":null, "desconto":null }, { "nQUarto": 2, "tarifa":{ "vlDiariaTotal":890.21, "desconto":null }, "qtDisponivel":null, "desconto":null }, ] } ] } ]
Is there any way I can filter the object with jQuery and keep all properties? Thanks!