zoukankan      html  css  js  c++  java
  • golang http.ResponseWriter valid json

    golang httpserver如果采用 fmt.Fprintf(w, result)来输出json数据时,若json数据包含%号,则会出现问题。

    输出结果里面会包含(MISSING)字样,造成json格式错误。

    把输出函数替换为w.Write即可。

    func Action(w http.ResponseWriter, r *http.Request) {
    
        var result string
        //.......................
    
        // fmt.Fprintf(w, result)
        w.Write([]byte(result))
    }
    
  • 相关阅读:
    bzoj1221
    hdu3377
    bzoj3930
    bzoj3976
    bzoj4237
    fzu1977
    hdu1693
    ural1519
    bzoj1264
    回答自己的提问
  • 原文地址:https://www.cnblogs.com/enumx/p/12313083.html
Copyright © 2011-2022 走看看