golang invalid character 'b' looking for beginning of value

后端 未结 4 1902
半阙折子戏
半阙折子戏 2021-01-04 07:35

I am trying to post a json with xml message inside it. However it returns

invalid character \'b\' looking for beginning of value

I think the possible reason

4条回答
  •  难免孤独
    2021-01-04 08:06

    The error indicates that the server did not return a valid JSON response. I suggest adding the following code to debug the issue:

    err := json.Unmarshal(resBody, v)
    if err != nil {
        log.Printf("error decoding sakura response: %v", err)
        if e, ok := err.(*json.SyntaxError); ok {
            log.Printf("syntax error at byte offset %d", e.Offset)
        }
        log.Printf("sakura response: %q", resBody)
        return err
    }
    

提交回复
热议问题