diff --git a/src/private/json.nim b/src/private/json.nim index 504d070..da3201c 100644 --- a/src/private/json.nim +++ b/src/private/json.nim @@ -38,6 +38,12 @@ proc jsonFromScalar(content: string, tag: TagId, of yTypeFloat: result.kind = JFloat result.fnum = parseFloat(content) + of yTypeFloatInf: + result.kind = JFloat + result.fnum = if content[0] == '-': NegInf else: Inf + of yTypeFloatNaN: + result.kind = JFloat + result.fnum = NaN of yTypeBoolTrue: result.kind = JBool result.bval = true diff --git a/src/yaml.nim b/src/yaml.nim index bb8c76c..95f5826 100644 --- a/src/yaml.nim +++ b/src/yaml.nim @@ -294,6 +294,13 @@ proc parseToJson*(s: Stream): seq[JsonNode] ## representation. The input may not contain any tags apart from those in ## ``coreTagLibrary``. Anchors and aliases will be resolved. Maps in the ## input must not contain non-scalars as keys. + ## + ## **Warning:** The special float values ``[+-]Inf`` and ``NaN`` will be + ## parsed into Nim's JSON structure without error. However, they cannot be + ## rendered to a JSON character stream, because these values are not part + ## of the JSON specification. Nim's JSON implementation currently does not + ## check for these values and will output invalid JSON when rendering one + ## of these values into a JSON character stream. proc parseToJson*(s: string): seq[JsonNode] ## see `parseToJson <#parseToJson,Stream,seq[JsonNode]>`_