Json Deserialization for ClassificationResult[] array

I am working with Document Understanding and it has a ‘DocumentProcessing.Contracts.Results.ClassificationResult’ object, which I need to Serialize and Deserialziar as json, xml or text.

Within assign activity a get the Json with ‘JsonConvert.SerializeObject()’ and serialization works great

With ‘JsonConvert.DeserializeObject<T>’ the deserialization works great in .Net, but not in UiPath Studio.

Apparently the validation does not understand the class typified in or <T> (array) and indicates an invalid ‘end of expresion expected’.

Other aproachs:
Using the Deserialize json activity returns a JArray, it returns a json but I can’t deserialize and instance of ‘ClassificationResult’ from there.
Using the Invoke Method is a solution, but it is not clear to me how to initiate it to ‘cast’ <T>.
Someone with a solution proposal that allows deserialziar tified objects from a json with ‘JsonConvert.DeserializeObject <T>’?
Finally the DirectCast does not work because the class ‘ClassificationResult’ does not have the ‘ornaments’ associated with classes that are serialized and deserialized.

is your code project set to C# or VB?

I did a test with both of them and worked successfully from .Net Studio (I only add the C# version to demonstrate the test on .net)

Observe here how I can invoke the function to serialize through an assign activiti without any problem

As you kow Newtonsoft.Json.JsonConvert is the base library for all associated DU components
We cannot consider a library incompatibility, if it were the initial conclusion

However, deserialization is another story


I consider that the specification of DeserializeObject**<ClassificationResult >** of type is what the UiPath Studio interpreter does not handle correctly, but it is only my intuition, but this is the correct way to parameterize the library for ‘JsonConvert.DeserializeObject’

the question was about what you are using within UiPath for a programming language to exclude syntax missmatch.

In case of VB give try on …DesererializeObject(Of ClassificationResult( ))(ClassResultText)

Exactly the help I needed, a fresh view that would identify my syntax error
I have a predilection for C# and I ended up transcribing my final code with this, without realizing the restriction of the final implementation language
Interesting, is that the serialization I wrote correctly with ‘()’ and not with ‘<>’.
Thanks so much!

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