root/geojson/trunk/tests/strict_json.txt

Revision 1504, 1.0 KB (checked in by mattrussell, 8 months ago)

Simplify code. Remove custom mapping object. add more tests for falling through to json, crs and strict json. Fixes #186

Line 
1GeoJSON enforces strict JSON
2----------------------------
3  GeoJSON produces and consumes only strict JSON.
4  NaN and Infinity are not permissible values according to the JSON specification.
5
6  >>> import geojson
7  >>> geojson.dumps({"type": "Point", "coordinates": [float("nan"), 1.0]}) # doctest: +ELLIPSIS
8  Traceback (most recent call last):
9              ...
10  ValueError:...not JSON compliant...
11
12 
13  >>> geojson.dumps({"type": "Point", "coordinates": [float("nan"), 1.0]}) # doctest: +ELLIPSIS
14  Traceback (most recent call last):
15              ...
16  ValueError:...not JSON compliant...
17
18  >>> json = '{"type": "Point", "coordinates": [1.0, NaN]}'
19  >>> geojson.loads(json) # doctest: +ELLIPSIS
20  Traceback (most recent call last):
21              ...
22  ValueError:...not JSON compliant...
23
24  >>> json = '{"type": "Point", "coordinates": [Infinity, -Infinity]}'
25  >>> geojson.loads(json) # doctest: +ELLIPSIS
26  Traceback (most recent call last):
27              ...
28  ValueError:...not JSON compliant...
29 
30 
Note: See TracBrowser for help on using the browser.