Hello everyone,
I’m having an issue while using a deserialized json to get a value.
“deserialize json: unexpected character encountered while parsing value: . path ‘’, line 0, position 0. uipath error”
I’m trying to do it with another method but it is not possible.
Hi @dhouha.cherif ,
Could you provide us with the Json Data that is being used ? Or a Screenshot of the Data ?
{
“code”: 804,
“message”: “Document signe”,
“signature_restant”: 5000576,
“date_consentmnt”: “28/10/2022 10:25:13”
}
If you do a copy and paste it is going to work but since it is the response of another API request i don’t know why it does not work. It’s like there is an invisible char before the json
In that case Peform a Debug and Check the values in the Immediate Panel. Let us know if you do find extra characters / spaces involved in the data, Maybe a Trim would help as well.
You could Take a Screenshot of the Immediate Panel and send it here after you have checked the values in the Data variables.
A Confirmation from the Immediate Panel will be much clear as to why the Error is happening. It does seem like a Trim is needed or Removal of Empty Lines.
Check by Logging resp
in Immediate Panel and resp.Trim
as well, addtionally perform the below as well :
resp.TrimStart(Environment.NewLine.ToCharArray)
It does seem that there are extra spaces at the beginning, Use resp.Trim
at first to Check if the Deserialization works else you could use the resp1
variable as you have already used TrimStart on the value and have obtained the modified value. Check both the Expressions in Deserialize Json
Activity and Check if it works.
if i understood right i should have something like this?
Yes. Does this setup work ?
From your screenshot we do see something like a comma on the begin
so lets try for a customized trim like
YourStringVar.Trim((","+" "+vbCrLf).ToCharArray)
Unfortunately , it did not work
Unfortunately , it did not work
no problem, check in the immediate panel following:
ASC(YourStringVar(0))
Let us know the result, please
For working with the immediate panel have a look here:
The only method that worked is to :
- Trim the input like you guys said
- Put the output in a text file
- read the text file and define an output variable
- Use the output variable for deserialize
We use "ASC(YourStringVar(0)) " for what exactly?I had as a response : 63
Could you let us know if it was the same error ?
Can you try following trimming (quick check in immediate panel is possible)
YourStringVar.Trim((Chr(63)+“,”+" "+vbCrLf).ToCharArray)
we analyzed the first character to get the details, which we use later for the custom trimming
as you can see in the immediate panel the trimming result looks good on the first check so far.
About further issues let us always know the exception message details as well