SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Leveraging UiPath .NET integration to build JSON in
a simple, readable and repeatable way
By Jack Dale
Monday, 24th October, 2022
www.vkyautomation.com
Contents
A Little Context
A Brief Tour of JSON
Building JSON Using UiPath Activities
Problems with the Activity Approach
Leveraging .NET integration
A Word of Warning
Going Further
Concluding Remarks
> Our automations must interact with a range of
applications and systems.
> UiPath has a sophisticated UI detection system,
but this may not be consistently reliable.
> Automations are at the mercy of the applications
they interact with.
> Alternatively, our automations can interact with
APIs.
> Major architectural styles: SOAP (typically uses XML)
and REST (typically uses JSON).
> REST requests can be complex and difficult to
construct in UiPath, but not anymore!
A little context
> Syntax borrowed from JavaScript.
> Composed of 6 core structures
> Objects -> ‘{ }’
> Arrays -> ‘[ ]’
> Strings
> Numbers
> true and false
> null
> Objects are made up of key-value pairs (called
“properties” in JS speak).
> Arrays can contain any of the structures, but not
key-value pairs.
> Arrays are non-homogenous: an array can hold
objects and strings and numbers etc.
JSON (briefly)
{
"createdAt": "2019-03-29T12:24:08.129Z",
"firstName": "Dereck",
"managerID": 86918,
"lastName": "Upton",
"title": "Mr.",
"jobTitle": "Legacy Mobility Agent",
"city": "New Imogeneberg",
"workingPattern": 29262,
"workEmail": "dereckUpton22@gmail.com",
"workMobile": "262-672-5659",
}
Demo
> To construct the previous example using UiPath
would require:
> An assign activity to create the top-level JSON object.
> 10 Invoke Method activities to add each property to
the top-level JSON object.
> Perhaps an assign activity to format the date-time
for ‘createdAt’.
> What about activities to format phone numbers and
emails?
> Things can get worse…
Constructing JSON using UiPath activities
{
"executionID": "09effed7-6520-46d7-8abe-b1e1d15657b8",
"supportedCPUTargets":[
"ARM",
"Intel",
"AMD"
],
"runningTime": 5700,
"recommendedExecEnv": [
{
"cpuType": "ARM",
"coreCount": 4,
"ram": 16,
"virtualization": false
},
{
"cpuType": "Intel",
"coreCount": 4,
"ram": 8,
"virtualization": true
},
{
"cpuType": "AMD",
"coreCount": 6,
"ram": 32,
"virtualization": null
},
"Windows",
"Mac",
"Debian"
]
}
Demo
> Workflow pollution:
> Lots of almost exact duplicates of a single activity,
just with different parameters.
> Reduced readability:
> Non-standard differentiation - how should we tell the
difference between each activity? With comments?
Annotations? Renamed activities?
> Likely to make a mistake if adding more
properties later in development:
> One of the already existing activities must be copied,
pasted, relabelled, and its arguments changed to the
required values.
Problems with the activity approach
> As UiPath is built on .NET, we can use its
integration to our advantage.
> Use the ‘dynamic’ C# keyword.
> Bypasses compile-time type checking.
> Checks are done at run-time instead.
> Let's us add properties to a JObject in a manner
more akin to actual JavaScript.
> There are exceptions to the rule.
> No more untidiness!
> A single Invoke Code activity compared to many
Assign’s and Invoke Method’s.
Have no fear, Invoke Code is here!
Demo
> VB.NET does not have a ‘dynamic’ keyword equivalent.
> Instead use ‘Option Strict Off’.
> UiPath has ‘Option Strict On’ by default - there is no way to turn it off.
> We can still reap the benefits of Invoke Code, we just can’t build JSON JS-style.
A sidenote about VB.NET
> Certain property names can only be added using
the ‘Add’ method.
> This is easy to do though, simply type:
<jObj>.Add(<property name>, <value>);
> Where:
> <jObj> = the name of your JObject
> <property name> = your property name*
> <value> = the value being added
* Property names that are not alpha-numeric or
‘_’ must be added with the Add method.
* Google provide a best-practice style guide, found
here
A word of warning
> We’ve discussed building JSON to send REST
requests, but what about receiving responses?
> Believe it or not, the very same principles apply:
> JSON responses can be complex and deeply nested.
> We could extract the data we need using UiPath
activities, but…
> Unless the JSON structure is very simple, we will fall
into the same trap as when sending requests.
> As before, we can simplify our workflows using
invoke Code, but there’s a twist.
> To help us extract the data we need, we can use a
language feature called LINQ, but that is a story for
another time…
Going further
> Using an API is always preferable to interacting with GUIs.
> Constructing JSON doesn’t need to be arduous and
complicated.
> Adding JSON properties using standard activities is
cumbersome and makes workflows unreadable.
> We can replace our activities with a single Invoke Code.
> Using ‘dynamic’ to bypass static type checking combined
with the JObject .NET class, we can compact JSON
construction to a single activity.
> Property names which contain non-alpha-numeric
characters (except ‘_’) must be added using Add.
Concluding remarks

Contenu connexe

Similaire à Leveraging UiPath .NET integration to build JSON

Rails and iOS with RestKit
Rails and iOS with RestKitRails and iOS with RestKit
Rails and iOS with RestKit
Andrew Culver
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 

Similaire à Leveraging UiPath .NET integration to build JSON (20)

Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
How to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdf
How to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdfHow to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdf
How to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdf
 
Rails and iOS with RestKit
Rails and iOS with RestKitRails and iOS with RestKit
Rails and iOS with RestKit
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
 
"Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin "Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin
 
Fighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkFighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with Embulk
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guide
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Google cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstractionGoogle cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstraction
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 

Plus de Cristina Vidu

Steps towards RPA Development: Create a Process Assessment Matrix
Steps towards RPA Development: Create a Process Assessment Matrix Steps towards RPA Development: Create a Process Assessment Matrix
Steps towards RPA Development: Create a Process Assessment Matrix
Cristina Vidu
 
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
Cristina Vidu
 
Think before we automate
Think before we automateThink before we automate
Think before we automate
Cristina Vidu
 

Plus de Cristina Vidu (20)

Communauté UiPath Suisse romande - Séance de janvier 2024
Communauté UiPath Suisse romande - Séance de janvier 2024Communauté UiPath Suisse romande - Séance de janvier 2024
Communauté UiPath Suisse romande - Séance de janvier 2024
 
State of the Automation Professional 2023: Insights and Implications for Nigeria
State of the Automation Professional 2023: Insights and Implications for NigeriaState of the Automation Professional 2023: Insights and Implications for Nigeria
State of the Automation Professional 2023: Insights and Implications for Nigeria
 
Steps towards RPA Development: Create a Process Assessment Matrix
Steps towards RPA Development: Create a Process Assessment Matrix Steps towards RPA Development: Create a Process Assessment Matrix
Steps towards RPA Development: Create a Process Assessment Matrix
 
Dev Dives: Design user-friendly attended automations from A to Z
Dev Dives: Design user-friendly attended automations from A to ZDev Dives: Design user-friendly attended automations from A to Z
Dev Dives: Design user-friendly attended automations from A to Z
 
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
Dev Dives: Unlock AI-driven automation with semantic automation & communicati...
 
Advocating for the customer. Bringing soft skills into software development
Advocating for the customer. Bringing soft skills into software developmentAdvocating for the customer. Bringing soft skills into software development
Advocating for the customer. Bringing soft skills into software development
 
🌺 Women in Automation Program: Become an RPA Developer with UiPath Studio Ses...
🌺 Women in Automation Program: Become an RPA Developer with UiPath Studio Ses...🌺 Women in Automation Program: Become an RPA Developer with UiPath Studio Ses...
🌺 Women in Automation Program: Become an RPA Developer with UiPath Studio Ses...
 
Steps towards RPA Development: How to Document your Automation.pdf
Steps towards RPA Development: How to Document your Automation.pdfSteps towards RPA Development: How to Document your Automation.pdf
Steps towards RPA Development: How to Document your Automation.pdf
 
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
 
Women in Automation - Intro to Studio Session 1
Women in Automation - Intro to Studio Session 1Women in Automation - Intro to Studio Session 1
Women in Automation - Intro to Studio Session 1
 
Think before we automate
Think before we automateThink before we automate
Think before we automate
 
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
🌺 Women in Automation Program: Become a Citizen Developer with UiPath StudioX...
 
Women in Automation - Introduction to RPA
Women in Automation - Introduction to RPAWomen in Automation - Introduction to RPA
Women in Automation - Introduction to RPA
 
Conversational AI and Chatbot Integrations
Conversational AI and Chatbot IntegrationsConversational AI and Chatbot Integrations
Conversational AI and Chatbot Integrations
 
RPA Karaoke
RPA Karaoke RPA Karaoke
RPA Karaoke
 
Let’s build an app with UiPath Apps!
Let’s build an app with UiPath Apps!Let’s build an app with UiPath Apps!
Let’s build an app with UiPath Apps!
 
Dev Dives: Unlock automation adoption with UiPath Apps
Dev Dives: Unlock automation adoption with UiPath AppsDev Dives: Unlock automation adoption with UiPath Apps
Dev Dives: Unlock automation adoption with UiPath Apps
 
UiPath Amsterdam DEV meet-up For Developers, By Developers
UiPath Amsterdam DEV meet-up For Developers, By DevelopersUiPath Amsterdam DEV meet-up For Developers, By Developers
UiPath Amsterdam DEV meet-up For Developers, By Developers
 
Jahresplanung und Content Map
Jahresplanung und Content MapJahresplanung und Content Map
Jahresplanung und Content Map
 
Webinar - Utilizzo delle WebApi dell'Orchestrator.pdf
Webinar - Utilizzo delle WebApi dell'Orchestrator.pdfWebinar - Utilizzo delle WebApi dell'Orchestrator.pdf
Webinar - Utilizzo delle WebApi dell'Orchestrator.pdf
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Leveraging UiPath .NET integration to build JSON

  • 1. Leveraging UiPath .NET integration to build JSON in a simple, readable and repeatable way By Jack Dale Monday, 24th October, 2022 www.vkyautomation.com
  • 2. Contents A Little Context A Brief Tour of JSON Building JSON Using UiPath Activities Problems with the Activity Approach Leveraging .NET integration A Word of Warning Going Further Concluding Remarks
  • 3. > Our automations must interact with a range of applications and systems. > UiPath has a sophisticated UI detection system, but this may not be consistently reliable. > Automations are at the mercy of the applications they interact with. > Alternatively, our automations can interact with APIs. > Major architectural styles: SOAP (typically uses XML) and REST (typically uses JSON). > REST requests can be complex and difficult to construct in UiPath, but not anymore! A little context
  • 4. > Syntax borrowed from JavaScript. > Composed of 6 core structures > Objects -> ‘{ }’ > Arrays -> ‘[ ]’ > Strings > Numbers > true and false > null > Objects are made up of key-value pairs (called “properties” in JS speak). > Arrays can contain any of the structures, but not key-value pairs. > Arrays are non-homogenous: an array can hold objects and strings and numbers etc. JSON (briefly)
  • 5. { "createdAt": "2019-03-29T12:24:08.129Z", "firstName": "Dereck", "managerID": 86918, "lastName": "Upton", "title": "Mr.", "jobTitle": "Legacy Mobility Agent", "city": "New Imogeneberg", "workingPattern": 29262, "workEmail": "dereckUpton22@gmail.com", "workMobile": "262-672-5659", }
  • 6.
  • 8. > To construct the previous example using UiPath would require: > An assign activity to create the top-level JSON object. > 10 Invoke Method activities to add each property to the top-level JSON object. > Perhaps an assign activity to format the date-time for ‘createdAt’. > What about activities to format phone numbers and emails? > Things can get worse… Constructing JSON using UiPath activities
  • 9. { "executionID": "09effed7-6520-46d7-8abe-b1e1d15657b8", "supportedCPUTargets":[ "ARM", "Intel", "AMD" ], "runningTime": 5700, "recommendedExecEnv": [ { "cpuType": "ARM", "coreCount": 4, "ram": 16, "virtualization": false }, { "cpuType": "Intel", "coreCount": 4, "ram": 8, "virtualization": true }, { "cpuType": "AMD", "coreCount": 6, "ram": 32, "virtualization": null }, "Windows", "Mac", "Debian" ] }
  • 10. Demo
  • 11. > Workflow pollution: > Lots of almost exact duplicates of a single activity, just with different parameters. > Reduced readability: > Non-standard differentiation - how should we tell the difference between each activity? With comments? Annotations? Renamed activities? > Likely to make a mistake if adding more properties later in development: > One of the already existing activities must be copied, pasted, relabelled, and its arguments changed to the required values. Problems with the activity approach
  • 12. > As UiPath is built on .NET, we can use its integration to our advantage. > Use the ‘dynamic’ C# keyword. > Bypasses compile-time type checking. > Checks are done at run-time instead. > Let's us add properties to a JObject in a manner more akin to actual JavaScript. > There are exceptions to the rule. > No more untidiness! > A single Invoke Code activity compared to many Assign’s and Invoke Method’s. Have no fear, Invoke Code is here!
  • 13. Demo
  • 14.
  • 15. > VB.NET does not have a ‘dynamic’ keyword equivalent. > Instead use ‘Option Strict Off’. > UiPath has ‘Option Strict On’ by default - there is no way to turn it off. > We can still reap the benefits of Invoke Code, we just can’t build JSON JS-style. A sidenote about VB.NET
  • 16. > Certain property names can only be added using the ‘Add’ method. > This is easy to do though, simply type: <jObj>.Add(<property name>, <value>); > Where: > <jObj> = the name of your JObject > <property name> = your property name* > <value> = the value being added * Property names that are not alpha-numeric or ‘_’ must be added with the Add method. * Google provide a best-practice style guide, found here A word of warning
  • 17. > We’ve discussed building JSON to send REST requests, but what about receiving responses? > Believe it or not, the very same principles apply: > JSON responses can be complex and deeply nested. > We could extract the data we need using UiPath activities, but… > Unless the JSON structure is very simple, we will fall into the same trap as when sending requests. > As before, we can simplify our workflows using invoke Code, but there’s a twist. > To help us extract the data we need, we can use a language feature called LINQ, but that is a story for another time… Going further
  • 18. > Using an API is always preferable to interacting with GUIs. > Constructing JSON doesn’t need to be arduous and complicated. > Adding JSON properties using standard activities is cumbersome and makes workflows unreadable. > We can replace our activities with a single Invoke Code. > Using ‘dynamic’ to bypass static type checking combined with the JObject .NET class, we can compact JSON construction to a single activity. > Property names which contain non-alpha-numeric characters (except ‘_’) must be added using Add. Concluding remarks