0
Eai guys, all right? ... I’m having a problem where I need to get a data block from a json file, being it:
{
"custom_fields": {
"[TS] A empresa em que você trabalha é": "uma fábrica/indústria",
"[TS] Setor da empresa": "Outros",
"[TS] Compra de Lubrificante": "Sim - acima de 2.000 litros",
"[TS] Função na empresa": "Técnico",
"[TS] Departamento da empresa": "Administração",
"[TS] Site": "SCP"
}
}
I’m trying a big problem to get the data where has bracket and space, because always gives the error: Syntaxerror: Unexpected token [
var JSONSource = JSON.stringify(requestData);
//Extrai dados do lead para inserção
for (var i = 0; i < leadData.length; i++) {
values.push([
JSONSource,
leadData[i].custom_fields.[TS] A empresa em que você trabalha é,
leadData[i].custom_fields.[TS] Setor da empresa,
leadData[i].[TS] Compra de Lubrificante,
leadData[i].[TS] Departamento da empresa,
leadData[i].[TS] Site
]);
}
Finally, I wanted to know how to get this same data with this formatting, and this formatting/ structure is coming from an API, so I can’t change the key of it.
Another thing is that I’m doing this in the google Sheets script, which uses the same engine as Js, but with its peculiarities, I’m having some difficulty because I have almost no knowledge in this type of script.
From now on I appreciate your help!
Thanks Tiago, I got it here. But my friend, because hell I can access some data leadData[i]. custom_fields.exemplo1 and this one does not, both of which have the same structure?
– Moises Fausto
@Moisesfausto I increased the answer with this your doubt.
– Tiago Sabadini