ogr2ogr produces invalid GeoJSON when multiple layers are involved (http://trac.osgeo.org/gdal/ticket/3842). For example:
ogr2ogr -f GeoJSON "$f.json" "$f" tracks routes
For me the bad GeoJSON seems to be a missing "] }" at the end of the file, but I don't know if that's consistent.
I'm trying to batch convert a number of GPX files. Some have tracks, some have routes; none have both. Is there a workaround that will work on both types?