BC3098 error while assigning a value in assign activity

Hi team,
I am receiving an error while assign below value in assign activity.
“[{“DiscountType”: “1”, “DiscountAmt”: “10”},{“DiscountType”: “2”, “DiscountAmt”: “25”},{“DiscountType”: “3”, “DiscountAmt” : “30”}]”
Please check below screenshot

.

Please help on this.

@manojmanu.rpa

Dim jsonString As String
jsonString = "[{""DiscountType"": ""1"", ""DiscountAmt"": ""10""},{""DiscountType"": ""2"", ""DiscountAmt"": ""25""},{""DiscountType"": ""3"", ""DiscountAmt"": ""30""}]"

Please try this


It’s not working please let me know which data type variable we have to create for this.

as it is asn assign, remove the part:

Dim jsonString As String

and use only (Right hand side):

"[{""DiscountType"": ""1"", ""DiscountAmt"": ""10""},{""DiscountType"": ""2"", ""DiscountAmt"": ""25""},{""DiscountType"": ""3"", ""DiscountAmt"": ""30""}]"

@manojmanu.rpa

Use it in assign activity
image

jsonString = "[{""DiscountType"": ""1"", ""DiscountAmt"": ""10""},{""DiscountType"": ""2"", ""DiscountAmt"": ""25""},{""DiscountType"": ""3"", ""DiscountAmt"": ""30""}]"

Thanks it’s worked but I need to generate a datatable with this could you please on this.

Hi @manojmanu.rpa

Try the below syntax in Assign actiivity:

jsonString = "[{""DiscountType"": ""1"", ""DiscountAmt"": ""10""},{""DiscountType"": ""2"", ""DiscountAmt"": ""25""},{""DiscountType"": ""3"", ""DiscountAmt"" : ""30""}]"

dt = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(jsonString)

Hope it helps!!

feel free to prototype it by yourself:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Kindly note: " ist just a visual escpaping of inner "

@manojmanu.rpa

Use Build datatable activity
Create Discount type and Discount Amount column
Use Deserialize Json Activity the JsonString is stored in Jsonarray
Then use linq query

dataTable=(From item In jsonArray
Select dataTable.Rows.Add(item("DiscountType").ToString(), item("DiscountAmt").ToString())).CopyToDataTable()

@manojmanu.rpa

Just copy thr same string

Use deserialize jsonarray activity

Then paste the string. In the json string input firld

Select type argument as datatable

The output you get would be a datatable

Also apart from that instead of string and all…directly use build datatable if a datatable with these values is needed

Cheers