Late to the game but will share my solution to this issue, as it surfaced for me in a Python Flask-based REST backend I was developing recently. You could have NaN values in your JSON, if your issue was similar to mine, albeit in Python.
My underlying issue
I too was getting "can't parse JSON" on the swagger side. Turns out that Python's standard library json
import will allow "modern" but not-officially-JSON types, such as "NaN". And doing some calculations with floats and voila...As a strict parser fails with a type such as NaN, it's worth checking that you don't have these in your request JSON response.
Solved it with an encoder class
Though not a Java-specific answer, maybe my Python solution can help you solve the issue.
json.dumps(yourdata, cls=NumpyEncoder)
Where NumpyEncoder
is some class that converts NaN
values to JSON and/or your acceptable specifications. It might be the case that you too can include some encoder class in your code to remove NaN and/or other artifacts.
See my so answer for Python implementation details.