Java 类com.mongodb.util.JSONCallback 实例源码

项目:Camel    文件:MongoDbBasicConverters.java   
@Converter
public static BasicDBObject fromInputStreamToDBObject(InputStream is, Exchange exchange) {
    BasicDBObject answer = null;
    try {
        byte[] input = IOConverter.toBytes(is);

        if (isBson(input)) {
            BSONCallback callback = new JSONCallback();
            new BasicBSONDecoder().decode(input, callback);
            answer = (BasicDBObject) callback.get();
        } else {
            answer = (BasicDBObject) JSON.parse(IOConverter.toString(input, exchange));
        }
    } catch (Exception e) {
        LOG.warn("String -> DBObject conversion selected, but the following exception occurred. Returning null.", e);
    } finally {
        // we need to make sure to close the input stream
        IOHelper.close(is, "InputStream", LOG);
    }
    return answer;
}
项目:gameserver    文件:JSON.java   
/**
 * Create a new parser.
 */
public JSONParser(String s, BSONCallback callback) {
    this.s = s;
    _callback = (callback == null) ? new JSONCallback() : callback;
}