miha
(Miha)
June 10, 2019, 1:58pm
1
Hi
When subject has something like " \ " (backslash) it will not unmarsh correctly this. How can I solve this issue.
tnx
type Ticket struct {
Requestor string `json:"requestor"`
Subject string `json:"subject"`
Text string `json:"text"`
TelefonicaID string `json:"telefonicaid"`
Circuitid string `json:"circuitid"`
}
err = json.Unmarshal(body, &t)
if err != nil {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("Wrong Json!"))
}
Hi
Is the backslash correctly used in the json you get? \n is newline \t tab and so on and \\ is just a backslash.
miha
(Miha)
June 10, 2019, 3:31pm
3
Hello
Just backslash in text, for exp for street address.
NobbZ
(Norbert Melzer)
June 10, 2019, 3:55pm
4
Can you please show us the raw JSON (or a simplified version of it) that makes problems as well as the the value of err
?
miha
(Miha)
June 10, 2019, 4:36pm
5
Hello guys
text in subject comes like:
{“requestor”:“miha@test.com”,“Subject”:“Test DE ESPA \321A, S.A.U 123321-SITEM-434343”,“Text”:“Pruebas API VENDOR Test”,“telefonicaid”:“INC000001069347”,“circuitid”: “12312321231”}
What I get from unmarshal is nothing, if there is " \ " in subject. If I remove it, then it will be ok and I will get data unmarshal. If I get some error? No, nothing, just data is not unamrshaled correctly.
NobbZ
(Norbert Melzer)
June 10, 2019, 4:40pm
6
Yeah, that is invalid JSON, I’ll assume that the quotes are just replaced by the forum software, still you need to escape the backslash:
{
"requestor": "miha@test.com",
"Subject": "Test DE ESPA \\321A, S.A.U 123321-SITEM-434343",
"Text": "Pruebas API VENDOR Test",
"telefonicaid": "INC000001069347",
"circuitid": "12312321231"
}
I’m pretty sure you will get somethin in err
that is non-nil
then…
invalid character ‘3’ in string escape code
system
(system)
Closed
September 8, 2019, 5:04pm
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.