Iterate through each values from Object datatype

Hi ,

I have an System.Object variable i.e Array of object lets say ‘MasterObjectVar’ , where i have suppose values stored like -
object[3] {
object[2] { "DENSITOMETER BUILDING INCLUDES: ANALYZER SHELTER, ", 100 },
object[2] { “VALVE, SWING CHECK, NPS 24, PN 100, FULL PORT, , AG,30 S”, 32 },
object[2] { “CRANE BRAND WEDGE GATE VALVE, FULL PORT, RF/RF/CATII, BGO”, 28 }
}

I want to loop through each object and then through each value in the object and process further in my program.
I am using For each item (object) in MasterObject(Array of object) , and now i want teh values of each item in the object. But i am not able to retrieve the items from this object. How can i achieve so ?
I have tried Object.tostring and then maybe split and many other options , but it does not work

@Prakash_Singh

In for each loop, define the object data type.

For ex. If it is Array of String …String This is for Master object For each loop data type.

Second iteration you should pick each item and select String as data type.

I am not able to Iterate 2nd time inside the 1st for each loop(i.e for each object in array of object) to get the exact values inside the object . It gives me an error for all data types, i select for 2nd iteration .Error- Disallows implicit conversion from object to Systems.Collections.IEnumerable

However , when i try to print the datatype of the object inside 1st for each loop using writeline i.e item.getType().tostring, it prints the value- System.object

Now how should be the 2nd iteration ?

Well can you share SS or XAMl, That would help understand this query better.

I have used Python scope and output of that python code is an array of object , which i need to iterate through furtherPythonActivitiesTest.zip (31.2 KB)

image

Please change you object to Array of Object

Thanks , that worked well.

I am stuck with one other issue. Hope you can help. I need to pass dictionary variable as my input parameter to the invoke python method activity .
The python script works well with dictionary and gives me desired output at python terminal. But while passing dictionary variable as parameter in the invoke python method , it gives me error.
Exception message :Arrays’ is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example,
by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.

I saw some threads for coverting dict to json and converting back json to dict in python script. But i am unaware of JSon. Any other way to do so ?

1 Like

I was able to parse through the JSON string, so all set for now. However thanks for the help with previous issue @Lakshay_Verma

1 Like

@Prakash_Singh Happy Automation :slight_smile:
Please close thread by marking your answer as solution.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.