@@ -12,6 +12,7 @@ module Json.Encode
1212 , string
1313 , bool
1414 , int
15+ , number
1516 , null
1617 , dict
1718 , list
@@ -25,6 +26,7 @@ import Control.Arrow ((***))
2526import qualified Data.ByteString.Char8 as BSC
2627import qualified Data.ByteString.Builder as B
2728import qualified Data.Map as Map
29+import qualified Data.Scientific as Sci
2830import Data.Monoid ((<>))
2931import qualified Data.Text as Text
3032import qualified Numeric
@@ -41,6 +43,7 @@ data Value
4143 | String B.Builder
4244 | Boolean Bool
4345 | Integer Int
46+ | Number Sci.Scientific
4447 | Null
4548
4649
@@ -74,6 +77,11 @@ int =
7477 Integer
7578
7679
80+number :: Sci.Scientific -> Value
81+number =
82+ Number
83+
84+
7785null :: Value
7886null =
7987 Null
@@ -150,6 +158,9 @@ encodeUgly value =
150158 Integer n ->
151159 B.intDec n
152160
161+ Number scientific ->
162+ B.string7 (Sci.formatScientific Sci.Generic Nothing scientific)
163+
153164 Null ->
154165 "null"
155166
@@ -242,7 +253,7 @@ encodeSequence :: B.Builder -> B.Builder -> (BSC.ByteString -> a -> B.Builder) -
242253encodeSequence open close encodeEntry indent first rest =
243254 let
244255 newIndent =
245− indent <> "\t"
256+ indent <> " "
246257
247258 newIndentBuilder =
248259 B.byteString newIndent