Closed aazuspan closed 2 years ago
If you look at the json
field for that style, it contains "comments" that are not valid JSON. For example:
[{"color":"#efe9e4"},{"lightness":-10}]},//-----HideslabelsforPointsofInterests-----
To make that style work, those comments will need to be parsed and removed. Other styles should be searched for similar patterns that would break JSON parsing.
Running json.loads
on all of the styles fails with 5 styles:
Next step is to diagnose why the other styles are failing (they don't include //
like Bright & Bubbly) and see if they can be repaired automatically. If not, they may need to be dropped (not bad to lose 5 out of 23k styles). Also worth noting that these problem styles are within the first 150 styles added, so my guess is that Snazzy Maps now applies more effective data cleaning and this problem shouldn't arise if new styles are added.
Still, it will be worth incorporating a json.loads
test into the data ingestion script to ensure new styles don't break.
Just finished diagnosing. The issues are (in order above):
Trailing commas and property names can be fixed by the dirtyjson package, but I'm hesitant to rely on that because it's not maintained. ast.literal_eval
can only fix trailing commas, not property names. Haven't found a solution for C-style comments yet, but probably regex :vomiting_face:
All 5 broken styles have been fixed with the newly ingested asset.
The updating script has been modified to automatically fix the existing issues and validate all JSON prior to CSV export (14c80b20acb4701d47d8a1f9738fc6605877b268).
The Bright & Bubbly style causes a JSON parsing error. This is the only style I've seen that fails, but there may be others.
To recreate:
Error: