Deserializing JSON error

Hello.

I’m trying to deserialize a json dataset, from an API, but the robot seems to have an issue executing the activity:

imagem

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: m. Path '', line 1, position 2.
   at Newtonsoft.Json.JsonTextReader.Read()
   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)

Can anyone kindly help on this?

The data and the robot relevant sourcecode is available here: JSON_deserialization_test.zip (13.8 KB)

Thanks in advance.

HI @tiagofreire,

I am seeing wrong json format in notepad file please correct and try again.Use below content
initial_json_data note pad file.
{"metadata":[{"colIndex":0,"colType":"String","colName":"id"},{"colIndex":1,"colType":"String","colName":"type"},{"colIndex":2,"colType":"String","colName":"label_pt_br"},{"colIndex":3,"colType":"String","colName":"label_en_us"},{"colIndex":4,"colType":"String","colName":"label_es_es"}],"queryInfo":{"totalRows":10},"resultset":[["a2fb5787-c0a6-4761-b927-21411872e3b2","Text","N° EDP (Espanha)","",""],["e73cad5d-36d3-4634-97b0-e487a87fef50","Text","N° EDP (Portugal)","",""],["d2b1e1f7-6e9f-4870-ba00-666491fdbd3e","Text","Telefone","",""],["ac49e5bd-581f-455d-8c85-1de1d68c6526","Text","N° EDP (Renováveis)","",""],["8485c07c-5cf0-4422-903b-5dd74b6d1b42","Date","Data de nascimento","",""],["b0916232-71f3-4434-b3c9-d96a6b3bceb7","Text","N° EDP (Brasil)","",""],["274fd2f2-2326-4d44-ba4d-41bd29dfb6e5","Text","Nº EDP (Aposentado)","",""],["bfcd5b01-e3ac-44b2-8a39-98aea13e799a","Date","Data de nascimento","",""],["f19566c8-6f7d-4cc0-8245-c9c8ce975ec9","List","Unidade","",""],["6b018d4f-18e7-4245-b3ef-c7cbfe457f5d","List","Vínculo","",""]]}

Regards,
Arivu

Yes, I see that, but it seems to be the json_data variable content immediately after receiving the API call response:

replace “”(double quote) to " (single quote)

strOutput.Replace("""",""")

Regards,
Arivu

I managed to replace the double quotes with this:

json_data.Replace(chr(34)+chr(34),chr(34))

Unfortunately, a similar issue remains:

imagem

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: :. Path '', line 1, position 10.
   at Newtonsoft.Json.JsonTextReader.Read()
   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)

JSON_deserialization_test_v2.zip (13.9 KB)

Could kindly get a hand on this? :slight_smile:

Thanks.