TransWikia.com

JSON Error? - Unfolding library - Bug or something else?

Geographic Information Systems Asked by Geosphere on December 17, 2020

While trying to make use of GeoJSONReader from the Unfolding Library, while compiling I got the following error:

A JSONObject text must begin with '{'
JSON Error: Expected a ':' after a key
org.json.JSONException: Expected a ',' or '}' at 28 [character 29 line 1]
    at org.json.JSONTokener.syntaxError(Unknown Source)
    at org.json.JSONObject.<init>(Unknown Source)
    at org.json.JSONObject.<init>(Unknown Source)
    at de.fhpotsdam.unfolding.data.GeoJSONReader.loadDataFromJSON(Unknown Source)
....
A JSONObject text must end with '}'
JSONObject["features"] not found.
JSONObject["features"] is not a JSONArray.
Exception in thread "Animation Thread" java.lang.RuntimeException: java.lang.NullPointerException

And it goes on…
First, I thought it had to do with the JSON itself so I tested via several JSON web validators and it looked fine. I even compared it to another JSON that I knew was working when I used it. And actually,there is no problem with it as it can be displayed on geojson.io, as in the SS.

enter image description here

Now, I’m not sure whether I did something wrong but I’m pretty sure this is the way to load up a GeoJSON/JSON.

List<Feature> busLine = GeoJSONReader.loadDataFromJSON(this, "mures/linia4_linie.geo.json");

Link to the json gist

Any ideas?

Specs: using Unfolding library from here in Eclipse Mars, JDK 1.8.0_91

I’ve used it more than several times already but never had this issue before.

2 Answers

In the end, it was an actual bug in version 0.9.6, an older version which I was using.

Solution: git clone or ask for a newer version at least 0.9.8 beta.

You can read more in the issue opened on GitHub.

Correct answer by Geosphere on December 17, 2020

I suppose that you used the 'loadDataFromJSON' method. You can use the method 'loadData' instead of the above one. This will not give the error.

Answered by infinity on December 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP