Fixes #26 Serialize JSON at the end to avoid issues