fix to remove trailing commas in resultant json