Let $S$ be the set of all $(x,y)\in \Bbb N^2$ such that $x<y$ and $\gcd(x,y)=1.$ For $q\in \Bbb Q$ with $0<q<1$ let $f(q) =(x,y)\in S$ such that $q=x/y.$ Then $f:\Bbb Q\cap (0,1)\to S$ is a bijection.
Consider the reverse-lexicographic order (i.e. backwards-dictionary order) $<^*$ on $S.$ That is, if $(x_1,y_1)$ and $(x_2,y_2)$ are in S then $(x_1,y_1)<^* (x_2,y_2)$ iff
(i) $\; y_1<y_2$ or (ii) $\; y_1=y_2 \land x_1<x_2.$
Observe that $<^*$ is a linear ("total") order.
Now for any $n\in\Bbb N$ there is exactly one $z\in S$ such that the set $$T(z)=\{w\in S: w=z\lor w<^*z\}$$ has exactly $n$ members (See Appendix below).
So for $q\in \Bbb Q$ with $0<q<1,$ let $g(q)=n$ iff $T(f(q))$ has exactly $n$ members. Then $g: \Bbb Q\cap (0,1)\to\Bbb N$ is a bijection. (Recall $f$ from the 1st paragraph).
Appendix. For $y'\in \Bbb N$ let $S(y')=\{(x,y')\in S\}.$ Then $S(y')$ is finite, with at most $y'-1$ members. So if $z=(x,y)\in S$ then $T(z)\subseteq \cup \{S(y'): y'\le y\}$ so $T(z)$ is finite. Now we have
(a). If $z$ and $z'$ are in $S$ with $z<^*z'$ then the finite set $T(z)$ is a proper subset of the finite set $T(z')$ so $T(z)$ has fewer members than $T(z').$
(b). $\;(1,2)$ is the $<^*$-least member of $S,$ so $T((1,2))$ has just one member.
(c). If $(x,y)\in S$ then there is a $<^*$-least $w\in S$ such that $(x,y)<^*w,$ namely
(c-i). $\; w=(x',y)$ where $x'$ is the least $x''>x$ such that $(x'',y)\in S$ IF such an $x''$ exists, or
(c-ii). $\; w=(1,y+1)$ if there is no such $x''$ as in (c-i).
And if $T((x,y))$ has $n$ members then $ T(w)$ has $n+1$ members.
So by induction on $n\in \Bbb N,$ by (b) and (c), for every $n$ there exists some $z\in S$ such that $T(z)$ has $n$ members; By (a) there is only one such $z.$
Remark: You may have noticed that $<^*$ is a well-order. That is, if $\emptyset\ne U\subseteq S$ then $U$ has a $<^*$-least member. If $<^*$ is a well-order on an infinite set $S$ and if $T(z)$ (as defined above) is finite for each $z\in S$ then $(S,<^*)$ is order-isomorphic to $(\Bbb N,<).$ The first few members of $S$ in $<^*$-increasing order are $(1,2),(1,3),(2,3),(1,4),(3,4),(1,5),...,$ corresponding to the rationals $1/2,1/3,2/3,1/4,3/4,1/5,...$