@@ -129,21 +129,6 @@ function encode_map.string(v)
129129 return ' "'
130130end
131131
132- local function convertreal (v )
133- local g = string_format (" %.16g" , v )
134- if tonumber (g ) == v then
135- return g
136- end
137- return string_format (" %.17g" , v )
138- end
139-
140- if string_match (tostring (1 / 2 ), " %p" ) == " ," then
141- local _convertreal = convertreal
142- function convertreal (v )
143- return string_gsub (_convertreal (v ), " ," , " ." )
144- end
145- end
146-
147132function encode_map .number (v )
148133 if math_type (v ) == " integer" then
149134 return string_format (" %d" , v )
@@ -155,7 +140,18 @@ function encode_map.number(v)
155140 elseif v >= huge then
156141 error (" Inf is not supported in JSON" )
157142 end
158- return convertreal (v )
143+ local g = string_format (" %.16g" , v )
144+ if tonumber (g ) == v then
145+ return g
146+ end
147+ return string_format (" %.17g" , v )
148+ end
149+
150+ if string_match (tostring (1 / 2 ), " %p" ) == " ," then
151+ local _encode_number = encode_map .number
152+ function encode_map .number (v )
153+ return string_gsub (_encode_number (v ), " ," , " ." )
154+ end
159155end
160156
161157function encode_map .boolean (v )
0 commit comments