Hi all,
I tried converting a large number of TH1 derivatives into JSON using ROOT.TBufferJSON.ConvertToJSON(x)
(from Python) and found that the resulting JSON is mal-formed.
This is due to NaN and Infinitiy values in the TH1s, especially +/-Inf is common in TProfile axis bounds. TBufferJSON represents them as “nan”/“inf”/"-inf" (without the quotes)[0], which it seems even JSROOT is unable to understand [1].
The Python JSON module expresses these as “NaN”/“Infinity”/"-Infinity", which is also not valid JSON [2] (the standard does simply not allow such values), but a syntax allowed in JavaScript and apparently accepted by a number of JSON parsers as an extension. So this would probably be a better choice.
Though some parsers are picky and will not allow any such values (looking esp. at databases, like the SQLite JSON extension [3] or Postgres JSONB [4]), so providing a “pure” output mode that removes Infs and NaNs (at the risk of losing information) might be worth considering as well.
What is your opinion on these things? Can we get this fixed on ROOT’s side?
Thanks,
Marcel
[0] Sample:
...
0, 0, 0, 0, 0],
"fErrorMode" : 0,
"fZmin" : -inf,
"fZmax" : inf,
"fTsumwz" : 12337.6925694346,
"fTsumwz2" : 13893.578925121,
"fBinSumw2" : []
}
[1] https://goo.gl/6LRsTU (CMS DQM GUI, needs certificate, might not work for non-CMS members)
[2] http://json.org/ , <link to rfc7159.txt>
[3] <sqlite docs>
[4] <postgres docs>
(sorry, not allowed to put links)
ROOT Version: 6.12/07 (provided by CMSSW)
Platform: slc6_amd64_gcc700
Compiler: GCC