Implement ToJson for &[T], and add tests. Closes #14619