开发者

BSON Message To Map in JAVA

开发者 https://www.devze.com 2023-02-16 11:54 出处:网络
We are currently sending messages to a Redis Queue, which is being picked up by our JAVA application.

We are currently sending messages to a Redis Queue, which is being picked up by our JAVA application.

Anyone have an idea how to convert the BSON message to a Map in JAVA?

Here is an example MSG in BSON we pop from the Redis queue:

\x16开发者_如何学JAVA\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00


You can use MongoDB Driver:

Parse your BSON data just like this:

    RawDBObject obj(your ByteBuffer buf );
    obj.toMap();

done.

https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/RawDBObject.java

or BSON official site may help:

http://bsonspec.org/#/implementation


You can use a BSON parser to parse your BSON input. Google gives me bson4jackson but I have never tried it myself.

0

精彩评论

暂无评论...
验证码 换一张
取 消