Robotic Process Automation (RPA)

Robotic Process Automation (RPA)

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Error converting JSON to table

    Posted Tue June 29, 2021 09:23 AM
    Hi!


    After a suceeded http request and a suceeded Map To JSON, when I try to map the JSON to table, the following is happening:

    The table columns are only 3 and the line are only 1.
    Here are the table columns:
    dynamic = which contains all the data, here is a sample of this column:
    "dynamic": [
    {
    "resultado": "38998051898",
    "resultadoPw": "af804548-52bc-43be-89f1-ff40ecda4a7d",
    "cli": null,
    "matricula": "573597",
    "nome": "PAULO RAFAEL LIMA",
    "cargo": "PORTEIRO/VIGIA",
    "lotacao": "UNIMONTES/ HOSPITAL UNIV./ MONTES CLAROS",
    "cidade": null,
    "data1": null,
    "data2": null
    },
    {
    "resultado": "38998051898",
    "resultadoPw": "0a4ae955-4bdc-4739-8e9a-5186a00dbdac",
    "cli": null,
    "matricula": "573597",
    "nome": "PAULO RAFAEL LIMA",
    "cargo": "PORTEIRO/VIGIA",
    "lotacao": "UNIMONTES/ HOSPITAL UNIV./ MONTES CLAROS",
    "cidade": null,
    "data1": null,
    "data2": null


    the second column is: success = true
    the third = message = connection ok.

    How can I convert the "dynamic" cell to a list<text> ?
    It stores a HUGE amount of table data in a single cell and I need to store it in a list for my bot to run, the rest of code depends on it.


    Thanks in advance!

    ------------------------------
    Mauro Sérgio Lima França
    ------------------------------


  • 2.  RE: Error converting JSON to table

    Posted Wed June 30, 2021 08:56 AM
    Hi,
    Can you share your script?

    For example, I was able to map like the following:
    defVar --name extractionSuccess --type Boolean
    defVar --name extractedTable --type DataTable
    defVar --name tableRows --type Numeric
    defVar --name tableColumns --type Numeric
    
    jsonToTable --json "{\"dynamic\": [\r\n{\r\n\"resultado\": \"38998051898\",\r\n\"resultadoPw\": \"af804548-52bc-43be-89f1-ff40ecda4a7d\",\r\n\"cli\": null,\r\n\"matricula\": \"573597\",\r\n\"nome\": \"PAULO RAFAEL LIMA\",\r\n\"cargo\": \"PORTEIRO/VIGIA\",\r\n\"lotacao\": \"UNIMONTES/ HOSPITAL UNIV./ MONTES CLAROS\",\r\n\"cidade\": null,\r\n\"data1\": null,\r\n\"data2\": null\r\n},\r\n{\r\n\"resultado\": \"38998051898\",\r\n\"resultadoPw\": \"0a4ae955-4bdc-4739-8e9a-5186a00dbdac\",\r\n\"cli\": null,\r\n\"matricula\": \"573597\",\r\n\"nome\": \"PAULO RAFAEL LIMA\",\r\n\"cargo\": \"PORTEIRO/VIGIA\",\r\n\"lotacao\": \"UNIMONTES/ HOSPITAL UNIV./ MONTES CLAROS\",\r\n\"cidade\": null,\r\n\"data1\": null,\r\n\"data2\": null\r\n}]\r\n}" --jsonPath "$.dynamic" extractionSuccess=success extractedTable=value tableRows=rows tableColumns=columns
    logMessage --message "Success: ${extractionSuccess}\r\nRows: ${tableRows}\r\nColumns: ${tableColumns}\r\nTable: ${extractedTable}" --type "Info"​


    ------------------------------
    Joba Diniz
    ------------------------------



  • 3.  RE: Error converting JSON to table

    Posted Wed June 30, 2021 10:29 AM
    Yes Joba Diniz, I sure can, there it is.

    The pain is in the last line, the variable varColuna1Linha1 is storing the whole JSON file retrieved from the http request and I need to store it in a data table.
    getTableCell --dataTable ${varParametros_EmpregadosMGS} --column 1 --row 1 varColuna1Linha1=value

    begin of script:
    -----------------------------------------------------------------------------------
    defVar --name varURL_Autenticacao --type String --value "http://ti08:8086/api/porteiro" --parameter
    defVar --name varToken_Autenticacao --type String --value b88f39f8306875fc87rtbcb60eb15adad54e --parameter
    defVar --name varConexao_Okay --type Boolean --output
    defVar --name varDadosChamada --type String --output
    defVar --name dynamic --type DataTable
    defVar --name varParametros_EmpregadosMGS --type DataTable
    defVar --name varLinhas_Tabela --type Numeric
    defVar --name varColunas_Tabela --type Numeric
    defVar --name varColuna1 --type String
    defVar --name varColuna2 --type String
    defVar --name varColuna3 --type String
    defVar --name varColuna1Linha1 --type String
    defVar --name varLinha_1_Coluna_1 --type DataTable
    defVar --name var1String_de_Testes --type List --innertype String --value "[a,b,c,d,e,f,g,h]"
    defVar --name varitem1 --type String
    defVar --name varLista_Celulares --type List --innertype String
    defVar --name varPlayerID --type List --innertype String
    defVar --name resultado --type String

    executeScript --isfromfile --filename "D:\\Projetos\\Sistemas\\Automacao\\03. Desenvolvimento\\Porteiros noturnos\\Query_Porteiros.wal" --parameters "URL=${varURL_Autenticacao},Token=${varToken_Autenticacao}" --output "saidaChamadaBemSucedida=${varConexao_Okay},saidaDadosChamada=${varDadosChamada}"

    logMessage --message "\r\nSucesso da chamada = ${varConexao_Okay}" --type "Info"

    mapJson --json "${varDadosChamada}" --mappings "dynamic=${varParametros_EmpregadosMGS}"

    jsonToTable --json "${varDadosChamada}" --jsonPath "$" varParametros_EmpregadosMGS=value varLinhas_Tabela=rows varColunas_Tabela=columns
    getColumnName --dataTable ${varParametros_EmpregadosMGS} --index 1 varColuna1=value
    getColumnName --dataTable ${varParametros_EmpregadosMGS} --index 2 varColuna2=value
    getColumnName --dataTable ${varParametros_EmpregadosMGS} --index 3 varColuna3=value

    getTableCell --dataTable ${varParametros_EmpregadosMGS} --column 1 --row 1 varColuna1Linha1=value

    end of script
    -------------------------------------------------------------------------------------------

    ------------------------------
    Mauro Sérgio Lima França
    ------------------------------



  • 4.  RE: Error converting JSON to table

    Posted Wed June 30, 2021 10:51 AM
    Have you tried my script? it works. it converts your JSON to data table

    ------------------------------
    Joba Diniz
    ------------------------------



  • 5.  RE: Error converting JSON to table

    Posted Wed June 30, 2021 12:44 PM
    Yes, your script really ran fine.
    I found the difference: I just added the .dynamic after the $ in the jsonPath parameter.
    After this it ran fine too.

    jsonToTable --json "${varDadosChamada}" --jsonPath "$.dynamic" varParametros_EmpregadosMGS=value varLinhas_Tabela=rows varColunas_Tabela=columns

    Thank you very much! Appreciate it.

    ------------------------------
    Mauro Sérgio Lima França
    ------------------------------