It is a particularly effective method for totalitarian regimes as they can shield the public from viewing evidence supporting the claims of the dissident. It is also effective when the dissident has inherently eccentric behavior that can be magnified by the frustrations of dealing with the government's accusations.
With freedom of the press and the internet it is becoming an increasingly rare tactic.
The best defense is to communicate through an attorney, remain calm at all times, and amass as much evidence as possible before raising further dissent.
Doctor Johnson is engaged in political psychiatry to keep a lid on the mayor's corruption. The mayor paid Johnson to say Mr. Smith is crazy so the press would stop giving him interviews.