  We provide an abstract estimate of the form \[
  \|f-f_{Q,\mu}\|_{X \left(Q,\frac{\mathrm{d} \mu}{Y(Q)}\right)}\leq
c(\mu,Y)\psi(X)\|f\|_{\mathrm{BMO}(\mathrm{d}\mu)} \] for all cubes $Q$ in
$\mathbb{R}^n$ and every function $f\in \mathrm{BMO}(\mathrm{d}\mu)$, where
$\mu$ is a doubling measure in $\mathbb{R}^n$, $Y$ is some positive functional
defined on cubes, $\|\cdot \|_{X \left(Q,\frac{\mathrm{d} w}{w(Q)}\right)}$ is
a sufficiently good quasi-norm and $c(\mu,Y)$ and $\psi(X)$ are positive
constants depending on $\mu$ and $Y$, and $X$, respectively. That abstract
scheme allows us to recover the sharp estimate \[
  \|f-f_{Q,\mu}\|_{L^p \left(Q,\frac{\mathrm{d} \mu(x)}{\mu(Q)}\right)}\leq
c(\mu)p\|f\|_{\mathrm{BMO}(\mathrm{d}\mu)}, \qquad p\geq1 \] for every cube $Q$
and every $f\in \mathrm{BMO}(\mathrm{d}\mu)$, which is known to be equivalent
to the John-Nirenberg inequality, and also enables us to obtain quantitative
counterparts when $L^p$ is replaced by suitable strong and weak Orlicz spaces
and $L^{p(\cdot)}$ spaces.
  Besides the aforementioned results we also generalize Theorem 1.2 in
[OPRRR20] to the setting of doubling measures and obtain a new characterization
of Muckenhoupt's $A_\infty$ weights.
