How to write a matrix like this

I tryed this
$$
\begin{pmatrix}
J_0 & O &\cdots\\
0& J_{n+1} & 0\cdots
\end{pmatrix}
$$
I don't know how to do
How to write a matrix like this

I tryed this
$$
\begin{pmatrix}
J_0 & O &\cdots\\
0& J_{n+1} & 0\cdots
\end{pmatrix}
$$
I don't know how to do
Does one of these examples work for you?
\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
\(
\begin{pmatrix}
J_0 & 0 & \cdots & 0 \\
0 & J_{n+1} & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & J_r
\end{pmatrix}
\)
\(
\begin{pmatrix}
J_0 & 0 & \cdots & \\
0 & J_{n+1} & \cdots & \\
\vdots & \vdots & \ddots & \\
& & & J_r
\end{pmatrix}
\)
\end{document}
Result:
I personally like the left one better, it leaves less room for mis-interpretation.
See Why is \[ ... \] preferable to $$ ... $$? for why I used \( \) instead of $$ $$.
\ddots. – campa May 30 '18 at 16:02\[ … \]preferable to$$? – samcarter_is_at_topanswers.xyz May 30 '18 at 16:43