You could hack it using the TrimStart and TrimEnd string functions to remove the braces, or you could deserialise the response to a type that matches the structure of the JSON. For example, if response.Content is actually an array of strings, deserialise
to that:
Member
283 Points
1005 Posts
How can i convert a Json object field value to a string ?
Aug 07, 2020 03:35 AM|robby32|LINK
I manage to use the following to extract the errors from the response.content . I only get the first error:
dynamic responseErrors = JObject.Parse(response.Content);
var myerrorValue = responseErrors.Errors[0];
it produces something like {id value is incorrect}
the response is a RestResponse
How can i get the string value for this without the { }
thanks
All-Star
194854 Points
28099 Posts
Moderator
Re: How can i convert a Json object field value to a string ?
Aug 07, 2020 06:38 AM|Mikesdotnetting|LINK
You could hack it using the TrimStart and TrimEnd string functions to remove the braces, or you could deserialise the response to a type that matches the structure of the JSON. For example, if response.Content is actually an array of strings, deserialise to that:
string[] repsonseErrors = JsonSerializer.Deserialize<string[]>(response.Content);