code: function asJSON(rawElem) {
          var elem = jsify(rawElem);
          if (!_.isObject(elem)) {
              // Scalars should stay that way.
              return elem;
          }
          else if (_.isArray(elem)) {
              // Arrays must be recursively converted.
              return elem.map(function (e) { return asJSON(e); });
          }
          else if (isVertex(elem)) {
              // Handle Vertex
              return vertexToJson(asVertex(elem));
          }
          else if (isEdge(elem)) {
              // Handle Edge
              return edgeToJson(asEdge(elem));
          }
          else if (isTraversal(elem)) {
              // Handle Traversal
              return traversalToJson(asTraversal(elem));
          }
          else if (Tinkerpop.isJavaObject(elem)) {
              // If we still have an unrecognized Java object, convert it to a string.
              var javaObj = elem;
              return { 'javaClass': javaObj.getClass().getName(), 'toString': javaObj.toString() };
          }
          else if ('toJSON' in elem) {
              // If we have a 'toJSON' method, use it.
              return elem;
          }
          else {
              // Recursively convert any other kind of object.
              return _.mapValues(elem, function (value) { return asJSON(value); });
          }
      }
docs: #### `function asJSON(elem: any)` Converts an 'elem' to its json representation, using dynamic dispatch to handle essentially any type of elem.