Hi All,
I am trying to deserialiaze the Json data but getting an error
Deserialize JSON: Deserialized JSON type ‘Newtonsoft.Json.Linq.JArray’ is not compatible with expected type ‘Newtonsoft.Json.Linq.JObject’. Path ‘’, line 1, position 75.
Hi All,
I am trying to deserialiaze the Json data but getting an error
Deserialize JSON: Deserialized JSON type ‘Newtonsoft.Json.Linq.JArray’ is not compatible with expected type ‘Newtonsoft.Json.Linq.JObject’. Path ‘’, line 1, position 75.
Can Use the below syntax
syntax : Newtonsoft.json.jsonconvert.deserializeobject(of datatable)(jsonstring)
Cheers!
Note the difference between a jsonobject and a jsonarray.
For comparison: a string and a string[ ] are not the same. Here you have a similar problem.
If your http requests requires a jobject as input, but your data is in the form of a jarray either:
Yes the variable data type is datatable
I dont have to use the below activity then, just assign activity only for deseriliazation?
Yes use only assign font use deserialize json activity
Can you show an example. here my quoteResponseData_source is the output of http request which I am trying to deseriliaze it.
quoteResponseData_source
But I am getting error in further activities when I am trying to use use those values to replace the json body with the values obtained. I am trying to use those values obtained from assign activity in replacing the values in Json template .getting an error as jsonQuoteBody is of type
String
Hi @marina.dutta ,
Could you let us know if this error happens only when the INVALID SESSION
error occurs ?
Form the Logs we could see that there are two types of outputs - Json Object and Json Array.
Is the error happening only at some times ?
Yes the error happens sometimes when and also the request Time out error happens even though I increased the Timeout
In that case, maybe we could first check whether the output received is a Json Object and if it contains the Key “access_token” and then perform the Deserialization and next steps. If it is not a Json, we can simply throw an Error stating it was not recognised as a Json or Session Expiry has occurred.
For Json Type Check, we can do the below :
JToken.Parse(JarrOrJObj_Text).Type.Equals(JTokenType.Object) AndAlso JsonConvert.DeserializeObject(Of JObject)(JarrOrJObj_Text).ContainsKey("access_token")
For JArray, it would give False Output :
Also Note, Newtonsoft.Json.Linq
was also imported for this :
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.