Implement ToJson for &[T], and add tests. Closes #14619
auto merge of #14625 : japaric/rust/slice-tojson, r=alexcrichton

Let me know if the amount of tests is enough or too much.