boundary/folsom_cowboy — pull request #8 by syhpoon (2014-01-29 11:10:06+00:00)
Title: Properly string encode floats

When encoding values in mochijson2:json_encode_string/2 float values do not have a separate clause and crash the function. We're observing this behavior in our production.

For example this piece of data crashes the function as key is float:

```erlang
{histogram, [{0.019488, 24}]}
````

```
** Stacktrace: [{mochijson2,json_encode_string,[0.019488,{encoder,null,false}],[{file,"src/mochijson2.erl"},{line,173}]},{mochijson2,'-json_encode_proplist/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,166}]},{lists,foldl,3,[{file,"lists.erl"},{line,1197}]},{mochijson2,json_encode_proplist,2,[{file,"src/mochijson2.erl"},{line,170}]},{mochijson2,'-json_encode_proplist/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,167}]},{lists,foldl,3,[{file,"lists.erl"},{line,1197}]},{mochijson2,json_encode_proplist,2,[{file,"src/mochijson2.erl"},{line,170}]},{mochijson2,'-json_encode_proplist/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,167}]}]
```

I'm using io_lib:format in the patch because float_to_list/2 was introduced only in R16B.