views:

42

answers:

1

Hi all,

I'm currently learning the BSON java library for mongodb and I'm trying to transform a org.bson.BSONObject into XML in order to transform it with a XSLT stylesheet.

What kind of java types can I find as values in a BSONObject from a Mongodb ? Of course there will be:

  • BSONObject (internal doc)
  • java.lang.String
  • ???

what are the others ? BigDecimal and BigInteger ? boolean, int, long, double ? Timestamp.. etc... ??

thanks,

Pierre

+1  A: 

Had to search for it too, but according to this mongodb-dev post mapping is done like this:

 NULL            null
 UNDEFINED       null
 BOOLEAN         Boolean
 NUMBER          Double
 NUMBER_INT      Integer
 NUMBER_LONG     Long
 SYMBOL          String
 STRING          String
 OID             mongodb ObjectID
 REF             DBPointer
 DATE            Date
 REGEX           Pattern
 BINARY          DBBinary
 CODE            (exception)
 ARRAY           DBList
 OBJECT          DBObject or DBRef
 TIMESTAMP       DBTimestamp
 MINKEY          String: "MinKey"
 MAXKEY          String: "MaxKey" 

This article on mongodb.org is a good resource for it, too.

Edit: Had a look at the source: org.bson.types.* is having a number of classes for BSON types. org.bson.BSONDecoder is decoding a BSON string and does the mapping listed above.

halfdan