locationtech / locationtech/spatial4j
GeoJSONs cannot be read when the properties are ordered differently than expected
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 961
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
For example, reading this GeoJSON results in a NullPointerException:
{"coordinates":[[[1,0.01],[1,-0.01],[2,-0.02],[3,-0.01],[3,0.01],[1,0.01]]],"type":"Polygon"}
This might not be desirable behaviour, since JSON objects are unordered collections afaik and some JSON parsers do not preserve the order of the properties when serializing/deserializing, but instead order them alphabetically, for example.
It also sounds like this is not intended by the standard (https://www.rfc-editor.org/rfc/rfc7946#section-1.2):
"The ordering of the members of any JSON object defined in this
document MUST be considered irrelevant, as specified by [RFC7159]."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the NullPointerException with the Polygon GeoJSON shown in the issue, then trace the GeoJSON parsing entry point to find where member order is assumed. Confirm the fix by reading equivalent objects with different property orders and checking that both succeed without an exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100