Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -r9cdb38c7c44b7c94af338e90c089aa2e0cd77201 -r6cff9d9b2c329e124fafd745004950b2822eb548 --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 9cdb38c7c44b7c94af338e90c089aa2e0cd77201) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 6cff9d9b2c329e124fafd745004950b2822eb548) @@ -224,7 +224,8 @@ # # The methods "bson encode|decode" perform the low level type - # mapping. For now, this handles just the array notation. + # mapping between NX objects and the bson serialization. For now, + # this handles just the array notation. # :public method "bson decode" {bsontype value} { #puts stderr "bson decode of ${:name} /$bsontype/ '$value'" @@ -920,6 +921,14 @@ return $bson } + :public method "bson asJSON" {} { + # + # Return the current object in JSON syntax. + # + return [mongo::json::generate [:bson encode]] + } + + # # destroy a mapped object from memory # Index: library/mongodb/tests/nx-mongo.test =================================================================== diff -u -r3fc67997409b68627ed37c3b2c3a15ff8811df35 -r6cff9d9b2c329e124fafd745004950b2822eb548 --- library/mongodb/tests/nx-mongo.test (.../nx-mongo.test) (revision 3fc67997409b68627ed37c3b2c3a15ff8811df35) +++ library/mongodb/tests/nx-mongo.test (.../nx-mongo.test) (revision 6cff9d9b2c329e124fafd745004950b2822eb548) @@ -152,8 +152,11 @@ :property {password ""} } } ::User + #nsf::__profile_trace -enable false +::User create u1 -name GN -groups {admin teacher} +? {u1 bson asJSON} {{ "__class" : "::User", "groups" : [ "admin", "teacher" ], "name" : "GN", "password" : "" }} # check autoclosing nx::mongo::db close