Valid JS output?

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.13.0
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We use the Java driver to make requests against MongoDB instances, but also to output the JS that a user would have to execute to perform the same operation themselves (EG, in the mongo console). Using `toString` generally works – BasicDBObjects look like

      {"key": value}

      , etc. But `bson.types.Code` ends up outputting something like `{"scope": {"myFun": {"$code": "function ()

      {…}

      "}}}`, when it should be `{"scope": {"myFun": function () {…}}}}`.

      So … are we abusing toString too much? Is there some other operation that we can use to get the appropriate output? Or do we have to write the JS-compatible version ourselves?

      Thanks.

            Assignee:
            Unassigned
            Reporter:
            Greg Pfeil
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: