Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-514

BasicDBObject.toString() throw RuntimeException when contain Symbol

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.7.2
    • Component/s: API
    • Labels:
      None

      Code:

      		Mongo mongo = new Mongo();
      		DB db = mongo.getDB("wendal_test");
      		DBCollection ps = db.getCollection("person");
      		ps.drop();
      		BasicDBObject obj = new BasicDBObject();
      		obj.append("wendal", new Symbol("http://wendal.net"));
      		ps.save(obj);
      		
      		System.out.println(obj.toString());
      

      throw RuntimeException:

      Exception in thread "Main Thread" java.lang.RuntimeException: json can't serialize type : class org.bson.types.Symbol
      	at com.mongodb.util.JSON.serialize(JSON.java:261)
      	at com.mongodb.util.JSON.serialize(JSON.java:141)
      	at com.mongodb.util.JSON.serialize(JSON.java:58)
      	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:84)
      	at org.nutz.ztask.AllZTask.main(AllZTask.java:35)
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            wendal Wendal Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: