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))
}

golang http.ResponseWriter valid json的更多相关文章

  1. is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface | mongodb在windows和Linux导出出错

    执行mongoexport命令的时候 mongoexport --csv -f externalSeqNum,paymentId --host 127.0.0.1:27017 -d liveX -c ...

  2. Go实战--golang中使用JWT(JSON Web Token)

    http://blog.csdn.net/wangshubo1989/article/details/74529333 之前写过关于golang中如何使用cookie的博客: 实战–go中使用cook ...

  3. 【GoLang】golang HTTP GET/POST JSON的服务端、客户端示例,包含序列化、反序列化

    服务端代码示例: package main import ( "encoding/json" "fmt" "io/ioutil" " ...

  4. golang的xml、json解析

    xml golang的xml处理主要应用Unmarshal.Marshal方法实现,解析一个xml到struct如下,首先是xml文件: <?xml version="1.0" ...

  5. golang 自定义time.Time json输出格式

    工作中使用golang时,遇到了一个问题.声明的struct含time.Time类型.使用json格式化struct时,time.Time被格式化成”2006-01-02T15:04:05.99999 ...

  6. [转] golang中struct、json、map互相转化

    一.Json和struct互换 (1)Json转struct例子: type People struct { Name string `json:"name_title"` Age ...

  7. 八、golang文本操作、json协议

    一.终端读写 操作终端相关文件语句常量,go所有的都是接口 os.Stdin:标准输入 os.Stdout:标准输入,只要实现输出这个接口,打印到终端, os.Stderr:标准错误输出 os.Ope ...

  8. golang struct 定义中json``解析说明

    在代码学习过程中,发现struct定义中可以包含`json:"name"`的声明,所以在网上找了一些资料研究了一下 package main import ( "enco ...

  9. golang中如何将json文件解析成结构体

    package tool import ( "bufio" "encoding/json" "fmt" "os" ) t ...

随机推荐

  1. c#第一个程序-计算平方根

    上课教的内容.做笔记了. using System; using System.Collections.Generic; using System.ComponentModel; using Syst ...

  2. thinkphp 设置 支持模块多组

    正常的访问地址是:localhost/项目名/index.php/Admin/Index/index 模块分组之后呢:localhost/项目名/index.php/Admin/System/Inde ...

  3. C++ 函数的扩展②

    //函数扩展--默认参数和占位参数 (了解) #include<iostream> using namespace std; /* 可以将占位参数与默认参数结合起来使用 意义 为以后程序扩 ...

  4. ResultSet是结果集对象

    ResultSet是结果集对象 DriverManager管理一组驱动程序 PreparedStatement预编译的,用来发送和执行SQL语句的

  5. wpf中用户控件的属性重用

    我们经常会抽取一些可重用的控件,某个属性是否需要重用,直接决定了这个属性的绑定方式. 1.完全不可重用的控件 有一些与业务强相关的控件,它们的属性完全来自ViewModel,越是相对复杂的控件,越容易 ...

  6. windows CMD命令大全及详细解释和语法

    http://blog.csdn.net/god_7z1/article/details/51173067

  7. UNMET PEER DEPENDENCY @angular/common@2.3.1

    install of angular-cli results in unmeet peer dependencies. OSX 10.11.6node v6.9.1npm v3.10.8 [sudo] ...

  8. HDU 1058 Humble Numbers (动规+寻找丑数问题)

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  9. python练习题集合-1

    author:headsen chen  date : 2018-05-31  17:59:04 notice:本文素材来自于:<< 笨方法学python >> 这本书,由本人 ...

  10. Spring 集合注入

    Spring注入是spring框架的核心思想之一.在实际的开发中,我们经常会遇见这样一些类的注入,这些类中包含一些集合作为类的属性,那么要怎样想类中的集合注入数据呢?本文通过一个简单的示例向大家介绍一 ...