kazeburo/Kossy — pull request #3 by sonots (2013-08-08 05:06:18+00:00)
Title: json escape only for string

I got a JSON parse error when I posted a number to GrowthForecast (--enable-float-number). The returned JSON is as belows (indented):

{"llimit":-1000000000,"number":0,"stype":"AREA","mode":"gauge","adjustval":"1000000",
"meta":"{\"number\":0,\"mode\":\"gauge\",\"adjustval\":\"1000000\",\"meta\":\"\",\"data\":[],
\"unit\":\"sec\",\"adjust\":\"/\",\"md5\":\"8613985ec49eb8f757ae6439e879bb2a\"}",
"service_name":"0","gmode":"gauge","color":"#000000","created_at":"2013/06/2717:43:16",
"section_name":"0","ulimit":1e\u002b15,"id":90,"graph_name":"9"}

`"ulimit":1e\u002b15` is bad. It must be like `"ulimit":1e+15`, `+` must not be escaped because it is a float, not a string.

http://www.atmarkit.co.jp/ait/articles/0908/10/news087_2.html
> 文字列を生成する場合には、半角英数字（a-zA-Z0-9）以外の文字はすべて\uXXXXの形式でエスケープしておくとよいでしょう。

I changed the code to apply the escape conversion only for strings.