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.
rlgandu
(Rajyalakshmi Gandu)
July 30, 2024, 10:12am
2
@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.
ppr
(Peter Preuss)
July 30, 2024, 10:27am
4
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""}]"
rlgandu
(Rajyalakshmi Gandu)
July 30, 2024, 10:30am
5
@manojmanu.rpa
Use it in assign activity
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.
Parvathy
(PS Parvathy)
July 30, 2024, 10:41am
7
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!!
ppr
(Peter Preuss)
July 30, 2024, 10:42am
8
rlgandu
(Rajyalakshmi Gandu)
July 30, 2024, 10:52am
9
@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()
Anil_G
(Anil Gorthi)
July 30, 2024, 6:25pm
10
@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