Runtime Execution Error - Trouble Deserializing JSON Object

Hey all,

First post in the group.

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.

JSON object being returned:

{
“errorId”:0,
“solution”:
{
“text”:“NEED-THIS-VALUE”,
“url”:“XXXXXXX”
},
“cost”:“0.000700”,
“ip”:“46.98.54.221”,
“createTime”:1472205564,
}

Deserialize Properties
image

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.

Here’s the runtime error I’m receiving:
image

@JoshB plz use deserialize json array in the place of deserialize json.

1 Like

@venkatmalla6 Thanks for the reply!

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()

@JoshB if you don’t mind can you share the workflow once .

@JoshB
welcome to our community

fisrt of all add object name in json
like

“songs”:{
“errorId”:0,
“solution”:
{
“text”:“NEED-THIS-VALUE”,
“url”:“XXXXXXX”
},
“cost”:“0.000700”,
“ip”:“46.98.54.221”,
“createTime”:1472205564,

}
then try to convert them in to json array using Newtonsoft package

Thanks

Hello @JoshB
go through it

Hope it help you

Thanks

@venkatmalla6 @sandeep13

I have solved the mystery! :slight_smile:

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:

image

Thanks so much for everyone’s comments! Hopefully this helps someone in the future.

3 Likes

@JoshB
good to know that you slove this

Thanks

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??

Yes if you change the response of api it will be better otherwise you need to customize tlhe response

1 Like

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