We will use a concept "continued fraction" in
http://en.wikipedia.org/wiki/Continued_fraction
We use notation $ (a_0,a_1,a_2) = a_0 + 1/(a_1 + 1/a_2)$
Obviously we have
$ (0,0,a_0,\cdots,a_n) = (a_0,\cdots,a_n)$. (*)
For any $ r\in\mathbb {Q^ + }$, we can find a finite sequence $ a_n$ such that $ r = (a_0,a_1,a_2,\cdots,a_n)$.
We can force $ a_n>0,\forall n>0$. Then the sequence is unique.
Let $ f_n = 0$ when $ a_n$ even; $ f_n = 1$ when $ a_n$ odd.
We can define
$ f(r) = (0,[\frac {a_0}2],f_0 + [\frac {a_1}2],f_1 + [\frac {a_2}2],\cdots,f_n)$,
where $ [x]$ is the integer function.
Using (*), it is easy to verify $ f$ satisfies all the conditions.
Uniqueness can be also proved.