Writing JSON to the db in process