I’ve got a JSON object that I’m getting back from an API call but I’m just not able to parse it. I can deserialize other simple JSON objects, however this one has an extra object inside the JSON and I need to reach inside.
How I’m trying to read this after deserializing it:
jsonOutput(“solution”)(“text”).ToString
I found a similar topic that had some sample xaml files, but when I tried to open them in the studio it gave me an error and said the activities were invalid. So I did search and try to figure this one out on my own.
I changed the variable type to be “Newtonsoft.Json.Linq.JArray” and then replaced the deserialize with the deserialize array and here’s the error I receive. I don’t get any validation errors, this only happens when I try and step into the code.
RemoteException wrapping System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
'NewActivity': The private implementation of activity '1: NewActivity' has the following validation error: Compiler error(s) encountered processing expression "jsonApiResultsOutput".
Value of type 'Newtonsoft.Json.Linq.JArray' cannot be converted to 'Newtonsoft.Json.Linq.JArray'. Type mismatch could be due to mixing a file reference to 'C:\Users\jboddiford\.nuget\packages\newtonsoft.json\12.0.1\lib\net45\Newtonsoft.Json.dll' in project 'vbhost' with a file reference to 'C:\Users\jboddiford\AppData\Local\UiPath\app-19.6.0\Newtonsoft.Json.dll' in project 'vbhost'. If both assemblies are identical, try replacing these references so both references are from the same location.
at System.Activities.Validation.ActivityValidationServices.ThrowIfViolationsExist(IList`1 validationErrors, ExceptionReason reason)
at System.Activities.WorkflowInspectionServices.<GetActivities>d__3.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
at System.Linq.Enumerable.<ConcatIterator>d__58`1.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.<DistinctIterator>d__63`1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at UiPath.Executor.Tracking.TrackingHelpers.GetVariableNames(Activity activity)
at UiPath.Executor.Tracking.TrackingHelpers.TrackVariables(TrackingProfile profile, WorkflowInfo workflowInfo)
at UiPath.Executor.Tracking.DebugTrackingParticipant.RegisterWorkflow(WorkflowInfo workflowInfo)
at UiPath.Executor.Tracking.WorkflowTracking.RegisterWorkflowTracking(WorkflowInfo workflowInfo)
at UiPath.Executor.WorkflowRuntime.RegisterWorkflow(WorkflowInfo workflowInfo)
at UiPath.Executor.RobotRunner.InitWorkflowApplication()
at UiPath.Executor.RobotRunner.<ExecuteJob>d__61.MoveNext()
I have Visual Studio installed on this machine along with the UiPath studio and I think that the package installed via UiPath was duplicating references in the GAC. So I went ahead and removed the package from UiPath package manager and now I am no longer receiving the error about conflicting versions.
This JSON wasn’t working when I used the Deserialize Array activity because there are no brackets in the JSON string, however it DOES deserialize it when I used the non-array activity. From there I was able to access the string in the JSON Object by using the following Assign operation:
Thanks so much for everyone’s comments! Hopefully this helps someone in the future.
Took a while but I got there… I guess it’s just how the Deserialize JSON Array activity is expecting there to be brackets [ ] instead of { } which I totally understand. This API that I’m calling should probably have placed brackets in the JSON response to make it strictly adhere to the “array” formatting??