How to add a dynamic value in json using blueprism
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 09:48 AM
Hi,
We have a JSON format which needs to be sent as a input payload. How can we assign values in the JSON dynamically? We have values in the different data items and these values need to be replaced in the JSON.
For example:
I have json data:
{
"name": "xyz",
"Type": "Input"
}
In this, I need to replace the value xyz with other value from the data item dynamically using blueprism.
Can anyone please help on this.
------------------------------
Navitha K
------------------------------
We have a JSON format which needs to be sent as a input payload. How can we assign values in the JSON dynamically? We have values in the different data items and these values need to be replaced in the JSON.
For example:
I have json data:
{
"name": "xyz",
"Type": "Input"
}
In this, I need to replace the value xyz with other value from the data item dynamically using blueprism.
Can anyone please help on this.
------------------------------
Navitha K
------------------------------
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 02:09 PM
Hi,
I would try the Utility - JSON VBO and convert the JSON to a collection, do the updates on the collection, then convert back to JSON.
if it is something simpler then a string replace might be more suitable using a calc stage and Replace function.
peter
------------------------------
PeterLacken
Ren Røros Intelligent Automation
Peter.Lacken@rria.no
http://www.rria.no
------------------------------
I would try the Utility - JSON VBO and convert the JSON to a collection, do the updates on the collection, then convert back to JSON.
if it is something simpler then a string replace might be more suitable using a calc stage and Replace function.
peter
------------------------------
PeterLacken
Ren Røros Intelligent Automation
Peter.Lacken@rria.no
http://www.rria.no
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 02:23 PM
Hi Navitha
JSON is a string so you can directly use replace to replace the xyz with your new value.
Or you can extend the Utility - JSON VBO to convert the json string into a Dictionary and change the value, after which you can serialize and return the output.
Dim values = JsonConvert.DeserializeObject(json)
values(key) = newVal
op = JsonConvert.SerializeObject(values, Formatting.None)
------------------------------
Gopal Bhaire
Analyst
Accenture
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 03:07 PM
Today, i use the replace function, i write the default value, exemple "name": "%" and make Replace([DataJson];"%": [NewValue]) Or you can use regex expression for capture the value "XYZ" and make Replace([DataJson]; [CapturedValue];[NewValue])
------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
America/Recife
+5581988869544
If my answer helped you? Mark as useful!
------------------------------
------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
America/Recife
+5581988869544
If my answer helped you? Mark as useful!
------------------------------
Sr Cons at Avanade Brazil
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 03:24 PM
Are you working with the WebAPI service feature or a code stage? If you're using the WebAPI service feature to invoke a RESTful service you can select Template from the Request Body options and then add your JSON format as a template. Then you make the value portion of each element a parameter. Here's an example:


If you're doing this through a code stage/VBO, the answers provided by the other commenters should work well.
Cheers,
------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------
If you're doing this through a code stage/VBO, the answers provided by the other commenters should work well.
Cheers,
------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------
