Updated save json to database logic