{"ScriptPreparationCode":null,"TestCases":[{"Name":"forEach no dicion\u00E1rio","Code":"\r\ndictionary = () =\u003E ({\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCOde\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027,\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCOde\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027,\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCode\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027\r\n});\r\n\r\ntranslate = prop =\u003E dictionary()[prop];\r\n\r\nreplaceKey = (str, key) =\u003E {\r\n if (translate(key)) {\r\n const regex = RegExp(\u0060\\\\\u0022(${key})\\\\\u0022:\u0060, \u0027g\u0027)\r\n return str.replace(regex, \u0060\u0022${translate(key)}\u0022:\u0060)\r\n }\r\n}\r\n\r\nprintProp = json =\u003E {\r\n let jsonStr = JSON.stringify(json)\r\n const keys = Object.keys(dictionary());\r\n keys.forEach(key =\u003E {\r\n jsonStr = replaceKey(jsonStr, key)\r\n });\r\n return JSON.parse(jsonStr)\r\n};\r\n\r\nconst jsonTest = {\r\n saldoDisponivel: \u0027Test\u0027,\r\n limiteChequeEspecial: 24,\r\n totalLiquido: 7,\r\n saldoDisponivel: {\r\n irpf: 1,\r\n descricaoProfissao: 2\r\n },\r\n tipoTransacao: \u0027x\u0027\r\n};\r\n\r\nconst jsonFinal = printProp(jsonTest);\r\nconsole.log(jsonFinal);","IsDeferred":false},{"Name":"forEach no JSON","Code":"translate = prop =\u003E {\r\n const names = {\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCOde\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027,\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCOde\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027,\r\n tipoTransacao: \u0027type\u0027,\r\n movimentacaoExtrato: \u0027title\u0027,\r\n valor: \u0027value\u0027,\r\n dataHora: \u0027dateTime\u0027,\r\n saldoFinal: \u0027currentBalance\u0027,\r\n saldoDisponivel: \u0027balance\u0027,\r\n limiteChequeEspecial: \u0027overdraftLimit\u0027,\r\n saldoDisponivel: \u0027available\u0027,\r\n limiteTotalDisponivel: \u0027totalOverdraftLimit\u0027,\r\n totalInvestido: \u0027totalInvested\u0027,\r\n irpf: \u0027irpf\u0027,\r\n iof: \u0027iof\u0027,\r\n totalLiquido: \u0027netTotal\u0027,\r\n codigoProfissao: \u0027professionCode\u0027,\r\n descricaoProfissao: \u0027professionDescription\u0027\r\n };\r\n return names[prop];\r\n};\r\n\r\nreplaceKey = (str, key) =\u003E {\r\n if (translate(key)) {\r\n const regex = RegExp(\u0060\\\\\u0022(${key})\\\\\u0022:\u0060, \u0027g\u0027)\r\n return str.replace(regex, \u0060\u0022${translate(key)}\u0022:\u0060)\r\n }\r\n}\r\n\r\nconst toString = (json) =\u003E JSON.stringify(json)\r\n\r\nconst toJSON = (str) =\u003E JSON.parse(str)\r\n\r\nprintProp = json =\u003E {\r\n let jsonStr = toString(json)\r\n const keys = Object.keys(json);\r\n keys.forEach(item =\u003E {\r\n if (typeof json[item] === \u0027object\u0027) {\r\n const translatedJSON = printProp(json[item]);\r\n const parsedJSON = toJSON(jsonStr)\r\n parsedJSON[item] = translatedJSON\r\n jsonStr = toString(parsedJSON)\r\n }\r\n jsonStr = replaceKey(jsonStr, item)\r\n });\r\n return toJSON(jsonStr)\r\n};\r\n\r\nconst jsonTest = {\r\n saldoDisponivel: \u0027Test\u0027,\r\n limiteChequeEspecial: 24,\r\n totalLiquido: 7,\r\n saldoDisponivel: {\r\n irpf: 1,\r\n descricaoProfissao: 2\r\n },\r\n tipoTransacao: \u0027x\u0027\r\n};\r\n\r\nconst jsonFinal = printProp(jsonTest);\r\nconsole.log(jsonFinal);","IsDeferred":false}]}