encoder: Break apart the encoder into distinct modules + add call encoding
[luajson.git] / src / json / encode / others.lua
blob9c66bd42a85ab0651e9c4a7abff324dc66812cb1
1 local tostring = tostring
3 module("json.encode.others")
5 function encodeNumber(number, options)
6 local str = tostring(number)
7 if str == "nan" then return "NaN" end
8 if str == "inf" then return "Infinity" end
9 if str == "-inf" then return "-Infinity" end
10 return str
11 end
13 -- Shortcut that works
14 encodeBoolean = tostring
16 function encodeNil(value, options)
17 return 'null'
18 end