Closed Sasha4ever closed 7 years ago
because
>>> float('nan')
nan
>>> float('inf')
inf
>>> float('-inf')
-inf
@Sasha4ever - thanks. This raises a broader question:
1E6
be converted to a float or not? It's possible that it is an IDtrue
always be converted to boolean?True
to also represent a boolean?Because of the variety of possible conversions, you can pass an xml_fromstring
that uses the conversion method you prefer. For example:
>>> from lxml import etree
>>> from xmljson import XMLData
>>> XMLData(xml_fromstring=str, attr_prefix=None, dict_type=dict).data(etree.XML('<ROOT test="NAN"/>'))
{'ROOT': {'test': 'NAN'}}
Hope that resolves the issue.
IMHO XMLData shouldn't return invalid XML.
@Sasha4ever I don't see from your comments that XMLData is returning invalid XML. Can you elaborate ?
Ah, I think you mean return invalid JSON. Yes, that requires a fix.
The question is what would you like for these values in the resulting JSON output. To me it's unclear whether we want to fail the conversion, make it null or keep it as a string. Any insight you want to share ?