There are two extended json parsers in the mongo-java-driver project. One in the driver module, one in the bson module. The one in the driver itself only supports the $type field of the binary extended json representation to be an integer. There is an unreleased patch in master that also allows the hex representation:
The JsonReader parser in the bson module however ONLY supports the hex representation as can be seen in https://github.com/mongodb/mongo-java-driver/blob/c610f1853a4a3e9e5762e196adb076b647f418ac/bson/src/main/org/bson/json/JsonReader.java#L903
This means those to parsers are currently incompatible in their released forms. You can't create an extended json representation that works with both.
The com.mongodb.util.JSON parser chokes on
{ "$binary": "YWzDtmhh", "$type": "0" }
(until the next release).
The JsonReader parser in the bson module chokes on
{ "$binary": "YWzDtmhh", "$type": 0 }.
The JsonReader parser should be fixed to also support the int representation.
We are using both mongo-scala-driver and mongo-java-driver in our project, so we currently have a problem with this.