JSFiddle - React, Tailwind, and code Playground
JavaScript
var entrada = {
idPedido: 1,
dataCriado: "/Date(1454637600000-0200)/",
cliente: "Nome do Cliente",
pagamento: [{
idPgto: 1,
valor: 100.00,
tipoPgto: "dinheiro",
dataVenc: "/Date(1454637600000-0200)/"
}, {
idPgto: 2,
valor: 100.00,
tipoPgto: "cartĂŁo",
dataVenc: "/Date(1454657600000-0200)/"
}],
produtos: [{
idProduto: 1,
descricao: "bola",
valor: 200.00
}]
};
var regex = /Date\(([^\)]+)\)/;
var timestamp = /(\d{12,13})/
function converterData(obj, regex) {
Object.keys(obj).forEach(function(key) {
if (obj[key] instanceof Object) converterData(obj[key], regex);
else if (typeof obj[key] == 'string' && obj[key].match(regex)) {
var ts = parseInt(obj[key].match(timestamp)[0], 10);
obj[key] = new Date(ts);
}
});
return obj;
}
var saida = converterData(entrada, regex);
alert(JSON.stringify(saida, null, 4));