-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.12.0, 3.0.0
-
Component/s: JSON
-
None
Infinity is not part of the JSON spec, but neither is NaN, and the Mongo driver's parser seems to handle that case so should it not also handle Infinity?
This program demonstrates the problem.
TestMongoInfinity.java
public class TestMongoInfinity { public static void test(BasicDBObject obj) { String serializedObj = null; try { serializedObj = JSONSerializers.getStrict().serialize(obj); } catch (Throwable t) { System.out.println("Error during serialization"); t.printStackTrace(); } BasicDBObject deserialized = null; try { deserialized = (BasicDBObject)JSON.parse(serializedObj); } catch (Throwable t) { System.out.println("Error during deserialization"); t.printStackTrace(); } } public static void main(String[] args) { test(new BasicDBObject("val", Double.POSITIVE_INFINITY)); test(new BasicDBObject("val", Double.NEGATIVE_INFINITY)); } }