Exception in JSON Deserialize

Hi,

In my sequence I am reading JSON file and then deserializing it using Desrialize JSON activity. But the same XAML is working on other systems.
But I am getting the below error. Any help is much appreciated.

18.4.3+Branch.master.Sha.9888b477be8d3ec8a832306fc59c34ba6edad108

Message: Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘Newtonsoft.Json.Linq.JToken’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘data.name’, line 3, position 8.

Exception Type: Newtonsoft.Json.JsonSerializationException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘Newtonsoft.Json.Linq.JToken’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘data.name’, line 3, position 8.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at UiPath.Web.Activities.DeserializeJson`1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@Amrita1
The error says that the input data that you are sending is not in format. Is it possible to add the input data here to check the format?

BOM_Clinical_EAL.json (35 Bytes)

Please find attached.

Same json file and xaml are working on other systems.

did you ever solve this?

I’ve had the same. I perfectly normal procedure I use has suddenly packed in and won’t deserialise the json

My solution has been to roll back the version of json.net to 11.0.2.

How did you rollback to previous version? It didn’t allow to install the older version of nuget packages.

Hi @aditi1 .

rolling back can be done either by in the orchestrator processes section that is code to a lower version or in the Manage Packages version degrading/ Lowering down the package version. For example if Web.activities is currently running on 1.2.3 lowering it to 1.2.2

Thanks

Yeah but it doesn’t allow you to do so. If you choose a lower version, it gives you below error where you don’t have option to choose lower version

just click on “No”

Yes, I did that and you are back to previous original screen after doing that.

Can you share your code?

It’s working on other machines but only on my machine it is not working which I am guessing is definitely due to discrepancy in package versions.

Ok Lets give this a try, Copy the project.json of your project as a backup, Close the Studio, delete the project.json and open the code again.

It doesn’t allow you to open project without project.json. I had tried with xaml file but it was not opening the correct project folder in Studio. Instead it was opening all the other folders as well in that path.

I suppose you must be using RE framework, post deleting the project.json open the “Main” file first before any other xaml

Yes, you are right. Anyways, I had resolved the issue by making all the dependencies version same as my old project which was working fine. Thanks for the support.

1 Like

Cheers @aditi1 , kindly mark the correct option as per you as solution so that the thread can be closed and others can refer it :slight_smile:

I am not able to see Mark as solution option