Dict with `NaN` values been serialised to malformed JSON
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
Using Python 3.6
Below is the most basic example of the issue
**app.py**
```
@app.route('/mytest', methods=['GET'])
def mytest():
data = {
"number": float('NaN')
}
return data
```
This will return in this **invalid** JSON
```
{
"number": NaN
}
```
This is the same JSON which is generated by
```
data = {
"number": float('NaN')
}
json.dumps(data)
```
Contributor guide
Research direction
Start with the app.py reproduction and compare the endpoint response with Python's json.dumps(data) behavior for float('NaN'). Trace the response serialization entry point and its tests; done means the reported NaN case no longer produces malformed JSON, with the expected handling captured in a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100