#### `function asJSON(traversal: Java.Traversal)` Executes a traversal (synchronously!), returning a json object for all of the returned objects.
183952
function traversalToJson(traversal) {
        var array = traversal.toList().toArray().map(function (elem) { return asJSON(elem); });
        return JSON.parse(JSON.stringify(array));
    }
618560
function(object) {
    if (!this.stringify) return JSON.stringify(object);

    return this.stringify(object, function(key, value) {
      return (this[key] instanceof Array) ? this[key] : value;
    });
  }
210369
function() {
    if (this._isSerializing){ return this.id || this.cid; }
    this._isSerializing = true;
    var json = _.clone(this.attributes);
    _.each(json, function(value, name) {
        if( _.isNull(value) || _.isUndefined(value) ){ return void 0; }
        _.isFunction(value.toJSON) && (json[name] = value.toJSON());
    });
    this._isSerializing = false;
    return json;
  }
1329810
@Nullable
    private static Object json(@Nullable Object in) {
        if (in == null) return null;
        return new Object() {
            @Override
            public String toString() {
                return "{\"fake-key\": \"fake-value\"}";
            }
        };
    }
459917
function ToJSON(jsonName) {
        if (jsonName === 'result') jsonName = 'default';
        let args = Array.prototype.slice.call(arguments);
        if (typeof jsonName === 'undefined') {
          jsonName = 'default';
        } else if (typeof jsonName === 'string') {
          args.splice(0, 1);  //remove the name.
        }
        let jsonFn = modelObj.jsons[jsonName],
          result = this.dataValues;
        if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
          if (typeof modelObj.jsons['default'] === 'function') {
            result = modelObj.jsons['default'].apply(this, args);
          }
        } else {
          if (typeof modelObj.jsons[jsonName] === 'function') {
            result = modelObj.jsons[jsonName].apply(this, args);
          } else {
            result = this.dataValues;
          }
        }
        if (result === this) {
          result = this.dataValues;
        }
        if (typeof result === 'object' && result != null) {
          for (let i = 0; i < modelObj.privateAttributes.length; i++) {
            if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
              delete result[modelObj.privateAttributes[i]];
            }
          }
        }
        return result;
      }
918971
function (arr) {
    var jsonData = {};
    _.forEach(arr, function (elem) {
      var keys = Object.keys(elem);
      _.forEach(keys, function (key) {
        var value = elem[key];
        jsonData[key] = value;
      });
    })
    return jsonData;
  }
104603
function getJSON (response) {
  return response.json().then((body) => {
    if (body.status !== 'ok') {
      throw error(response, body.status, body.data[0])
    }
    return body
  })
}
866322
function isJSON(value, visited) {
    // Adding value to array of visited values.
    (visited || (visited = [])).push(value);
            // If `value` is an atom return `true` cause it"s valid JSON.
    return  isPrimitive(value) ||
            // If `value` is an array of JSON values that has not been visited
            // yet.
            (isArray(value) &&  value.every(function(element) {
                                  return isJSON(element, visited);
                                })) ||
            // If `value` is a plain object containing properties with a JSON
            // values it"s a valid JSON.
            (isFlat(value) && Object.keys(value).every(function(key) {
                var $ = Object.getOwnPropertyDescriptor(value, key);
                // Check every proprety of a plain object to verify that
                // it"s neither getter nor setter, but a JSON value, that
                // has not been visited yet.
                return  ((!isObject($.value) || !~visited.indexOf($.value)) &&
                        !("get" in $) && !("set" in $) &&
                        isJSON($.value, visited));
            }));
}
785528
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); });
        }
    }
741608
def asJSON(self):
        
        self._json = json.dumps(self.asDictionary)
        return self._json
384673
function processJson(obj) {
    for (var i in obj) {
      if (typeof(obj[i]) === "object") {
        processJson(obj[i]); // found an obj or array keep digging
      } else if (obj[i] !== null){
        obj[i] = getFunctionNameAndArgs(obj[i]);// not an obj or array, check contents
      }
    }
    return obj;
  }
486689
function(){
    var cached = {};
    var obj = {
        a: [1, 2, 3]
    }, json = "{\"a\":[1,2,3]}";
    
    if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
        // this is a working JSON instance
        return JSON;
    }
    if (Object.toJSON) {
        if (Object.toJSON(obj).replace((/\s/g), "") === json) {
            // this is a working stringify method
            cached.stringify = Object.toJSON;
        }
    }
    
    if (typeof String.prototype.evalJSON === "function") {
        obj = json.evalJSON();
        if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
            // this is a working parse method           
            cached.parse = function(str){
                return str.evalJSON();
            };
        }
    }
    
    if (cached.stringify && cached.parse) {
        // Only memoize the result if we have valid instance
        getJSON = function(){
            return cached;
        };
        return cached;
    }
    return null;
}
268969
@JsonValue
	public Object toJsonValue() {
		if (definition != null)
			return definition;
		if (reference != null)
			return reference;
		if (_null != null)
			return _null;
		return null;
	}
108027
function tryToParseJSON( json ) {
  if ( !isString( json ) ) return null;
  try {
    return JSON.parse( json );
  } catch ( e ) {
    return e;
  }
}
1330999
def asJSON(self):
        
        value = self._json
        if value is None:
            value = json.dumps(self.asDictionary,
                               default=_date_handler)
            self._json = value
        return self._json
549863
private Object readJSON() throws JSONException {
        switch (read(3)) {
        case zipObject:
            return readObject();
        case zipArrayString:
            return readArray(true);
        case zipArrayValue:
            return readArray(false);
        case zipEmptyObject:
            return new JSONObject();
        case zipEmptyArray:
            return new JSONArray();
        case zipTrue:
            return Boolean.TRUE;
        case zipFalse:
            return Boolean.FALSE;
        default:
            return JSONObject.NULL;
        }
    }
231772
def as_json(options = nil) #:nodoc:
            # use encoder as a proxy to call as_json on all elements, to protect from circular references
            encoder = options && options[:encoder] || ActiveSupport::JSON::Encoding::Encoder.new(options)
            map { |v| encoder.as_json(v) }
        end