Fixed printing of JSON-related objects and implemented writing json to a file