from APi call i get response like this
{
“id”: “1”,
“values”: [
{
“qty”: 1,
“pro”: “501”,
},
{ “qty”:2
“pro”: “502”,
}
],
i success to print the 2 “pro” in the out put ,while when i write in excel sheet cell it overwrite on the cell and write the last “pro”
while i need in excel sheet
colom1 id colom2 pro colom3 pro
while pro may be more than 2 or only 1 pro
any help for this? ,please as i new in uipath
Hi,
Try this:
jsonInput.Count.ToString
jsonInput.Item("values").Item(0).Item("qty").ToString
jsonInput.Item("values").Item(1).Item("qty").ToString
thank you…
jsonInput.Item("values").Item(0).Item("qty").ToString
but i iterate on several api and i dont know the index in item(0),(may i have 1 or 5 or 10) come from response
i need to make it dynamic to count how many item and print it
For Each: Accessed JArray values with invalid key value: “pro”. Int32 array index expected.
i got this error
Provide some issue screenshots or workflow please.
What is the full response looks like in strjson? Can you print response to file and share (of course anonymize sensitive data)?
What are your ForEach properties?
And Values condition?
json_object.Item(“items”).Item(“sku”)
Use:
ForEach itm in
json_object.Item(“items”)
or simpler:
ForEach itm injson_object(“items”)
Then:
Add data row
{itm.Item("sku").ToString}
or simpler:
{itm("sku").ToString}
thank you very very much i success to print it in excel sheet
if i want the result to be in next coloum in same row any help please
my pleasure for you
item.Item(“sku”).Item(“qty_ordered”).ToString
i try to print the quantity with sku put an error occur any help please?
try json to csv activity
item.Item(“sku”).Item(“qty_ordered”).ToString
is wrong.
item.Item(“qty_ordered”).ToString
is correct.
Look:
If you want take specific value from “items” you need to ask for KEY. For value you go down like stairs. By levels:
Keys:
“items” = level 0 (blue)
“qty_ordered” = level 1 (green)
“sku” = level 1 (green)
When you iterate thru “items” you iterate thru Key list to print value.
If you need assign specific value of “qty_ordered” type:
json_object(“items”)(0)("qty_ordered") = "1"
json_object(“items”)(1)("qty_ordered") = "2"
If you need assign specific value of “sku” type:
json_object(“items”)(0)("sku") = "7741"
json_object(“items”)(1)("sku") = "564"
if i need to make count on item.Item(“sku”).ToString
and made key dynamic variable
json_object(“items”)(variable)(“qty_ordered”)
as from api call i dont know how many sku come from the call may be 1 ,2 or more
and i need to print them in excel sheet