Let $R$ be a rectangle such that $X \subset R$. Since $X$ is $J-$measurable, the boundary $\partial X$ has measure zero. The integral over $X$ is given by
$$\int_X f = \int_R f \,1_{X}$$
where the$1_X$ denotes the indicator function.
$$1_X(x) = \begin{cases}1, \,\,\,\, x \in X,\\ 0, \,\,\,\, x \notin X \end{cases}.$$
Since $f \, 1_X = f \, 1_{X \setminus \partial X}$ except possibly on the measure zero set $\partial X$, we have
$$\tag{1}\int_X f = \int_R f 1_X = \int_R f 1_{X \setminus \partial X}.$$
Now consider Riemann sums for the integral on the right-hand side of (1). If a sub-rectangle of a partition $P$ intersects the boundary, choose a point on the boundary $\partial X$ as the intermediate point where the integrand $f \, 1_{X \setminus \partial X}$ is evaluated. Since the integrand has $0$ value at this point, there will be no contribution to the sum from sub-rectangles that intersect the boundary. However, as $|P| \to 0$ such Riemann sums converge to the integral on the right-hand side of (1) and consequently to the integral on the left-hand side.
To arrive at (1) we use the fact that if $h = f-g = 0$ except on a set $E$ of measure $0$, then $\int_R h = \int_R(f-g) = \int_R f - \int_R g = 0.$ This is relatively easy prove even in the context of Riemann integration. Given any partition P of $R$, every sub-rectangle $S$ has non-zero content and must contain a point $x$ where $h(x) = 0$. Hence, upper and lower Riemann sums satisfy
$$L(P,h) \leqslant 0 \leqslant U(P,h) $$
and
$$\int_R h = \sup_P L(P,h) \leqslant 0 \leqslant \inf_P U(P,h) = \int_R h \\ \implies \int_R h = 0$$