Robotic Process Automation (RPA)

 View Only
  • 1.  Map to JSON

    Posted Wed May 17, 2023 05:35 PM

    I tried to get data from a json in order to polulate an Excel file, so I'm using Map to JSON comand, like the image below

    When I run the bot an error shows.
    5/17/2023 4:33:51 PM - Error executing command at line 21: mapJson --json "${DataJson}" --mappings "{\"employee_name\":\"${Nombre}\",\"employee_salary\":\"${Salario}\",\"employee_age\":\"${Edad}\"}"
        Unexpected character encountered while parsing value: s. Path '', line 0, position 0.

    Thnaks for your help

    Alex Virrueta

  • 2.  RE: Map to JSON

    Posted Fri May 19, 2023 01:59 AM

    Dear Alex,

    I think the error is caused by unexpected characters in the Json, likely to be the brackets {} . 

    You may cross check the formatting of the Json file and how to fill in mappings from the documentation here

    There are some examples that you can copy over to RPA studio to test.


  • 3.  RE: Map to JSON

    Posted Tue May 23, 2023 09:05 AM
    Edited by Angelo Alves Tue May 23, 2023 09:06 AM

    Hi Alex, in mapJson in the left fields you must use the structure to find the attribute and not just its name.

    I am sending you an example code. 

    defVar --name phonenumberType --type String
    defVar --name employee_name --type String
    defVar --name age --type Numeric
    mapJson --json "{\n    \"employee_name\": \"John\",\n    \"employee_salary\": \"doe\",\n    \"person\": {\n        \"age\": 30\n    }\n}" --mappings "{\"$.employee_name\":\"${employee_name}\",\"$..age\":\"${age}\"}"
    logMessage --message "Name: ${employee_name}\r\nAge: ${age}" --type "Info"

    Angelo Alves
    IBM RPA Technical Specialist