BUG: to_json should raise exception for non-unique index / columns (#4359)

Issue #4359

to_json will raise ValueErrors where non-unique indices or columns would cause invalid JSON to be produced. Updated docstring and added some tests.