Skip to content

JSON output and infinity. #19768

@pcanal

Description

@pcanal

We have:

$ root.exe -b -l
root [0] struct Content { double d = std::numeric_limits<double>::infinity(); }
root [1] Content c;
root [2] auto s = TBufferJSON::ToJSON(&c)
(TString &) "{
  "_typename" : "Content",
  "d" : 2e308
}"[44]
root [3] Content *p = nullptr;
root [4] TBufferJSON::FromJSON<Content>(p, s)
libc++abi: terminating due to uncaught exception of type nlohmann::detail::out_of_range: [json.exception.out_of_range.406] number overflow parsing '2e308'
Abort trap: 6

At as side note we also have:

root [0] struct Content { double d = std::numeric_limits<double>::infinity(); }
root [1] Content *p = nullptr;
root [2] TString s = "{ \"_typename\" : \"Content\", \"d\" : null }"
(TString &) "{ "_typename" : "Content", "d" : null }"[39]
root [3] TBufferJSON::FromJSON<Content>(p, s)
(bool) true
root [4] p->d
(double) nan

So null represent nan rather than infinity.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions