In all trials for offenses within the jurisdiction of a district judge, the defendant or the state may demand a jury, which shall consist of six, or a less number, agreed upon by the state and accused, to be impaneled and sworn as in civil cases; or the trial may be by the judge. When the complaint is for a crime or misdemeanor in the exclusive jurisdiction of the superior court, the justice hears the case as a committing magistrate, and no jury shall be allowed.