Method: serialize.string
Transform a string into a JSON string.

Parameters:
string - {String} The string to be serialized

Returns:
{String} A JSON string representing the string.
976881
function(string) {
            // If the string contains no control characters, no quote characters, and no
            // backslash characters, then we can simply slap some quotes around it.
            // Otherwise we must also replace the offending characters with safe
            // sequences.    
            var m = {
                '\b': '\\b',
                '\t': '\\t',
                '\n': '\\n',
                '\f': '\\f',
                '\r': '\\r',
                '"' : '\\"',
                '\\': '\\\\'
            };
            if(/["\\\x00-\x1f]/.test(string)) {
                return '"' + string.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                    var c = m[b];
                    if(c) {
                        return c;
                    }
                    c = b.charCodeAt();
                    return '\\u00' +
                        Math.floor(c / 16).toString(16) +
                        (c % 16).toString(16);
                }) + '"';
            }
            return '"' + string + '"';
        }
295299
function stringifyVal(val) {
  return JSON.stringify(
    val,
    (key, val) => {
      if (typeof val === 'function') {
        if (val.name) {
          return `[Function: ${val.name}]: ${val.toString()}`
        } else {
          return `[Function]: ${val.toString()}`
        }
      }
      return val
    },
    2
  )
}
901727
def serialiseString(self, s):
        
        if type(s) is unicode:
            s = self.context.getBytesForString(s)

        l = len(s)

        if l > 0xffff:
            self.stream.write_ulong(l)
        else:
            self.stream.write_ushort(l)

        self.stream.write(s)
698966
def json_to_string(value, null_string_repr='[]', trimable=False):
    
    return null_string_repr if is_undefined(value) \
        else obj.jsonify(value, trimable=trimable)
1139081
private static JSON toJSON( String string, JsonConfig jsonConfig ) {
      JSON json = null;
      if( string.startsWith( "[" ) ){
         json = JSONArray.fromObject( string, jsonConfig );
      }else if( string.startsWith( "{" ) ){
         json = JSONObject.fromObject( string, jsonConfig );
      }else if( "null".equals( string ) ){
         json = JSONNull.getInstance();
      }else{
         throw new JSONException( "Invalid JSON String" );
      }

      return json;
   }
22055
def from_string(cls, string, exists=False, asynchronous=False, verbose=False):
        
        result = cls.parse(string)

        if result.scheme not in cls.TYPES:
            raise CopyError("Invalid scheme: %s" % (result.scheme))

        return cls.TYPES[result.scheme](result, exists, asynchronous, verbose)
140716
public Object stringToObject(String string)
    {
        Object obj = BaseTransport.convertStringToObject(string);
        return obj;
    }
1264211
def load_json_from_string(string):
    """"""
    try:
        json_data = json.loads(string)
    except ValueError as e:
        raise ValueError('Given string is not valid JSON: {}'.format(e))
    else:
        return json_data
403075
function serialize( arr ) {
	var len = arr.length,
		n = len - 1,
		str,
		i;

	str = '[';
	for ( i = 0; i < len; i++ ) {
		str += arr[ i ];
		if ( i < n ) {
			str += ',';
		}
	}
	str += ']';

	return 'new '+arr.constructor.name+'('+str+')';
}
711446
function decode (string) {
  var body = Buffer.from(string, 'base64').toString('utf8')
  return JSON.parse(body)
}
615763
function string(str) {
  assertString(str);
  var expected = "'" + str + "'";
  return Parsimmon(function(input, i) {
    var j = i + str.length;
    var head = input.slice(i, j);
    if (head === str) {
      return makeSuccess(j, head);
    } else {
      return makeFailure(i, expected);
    }
  });
}
715054
function stringToBuffer(str) {
    var buf = new Buffer(str.length);
    for (var i = 0; i < buf.length; i++) {
      buf.writeUInt8(str.charCodeAt(i), i);
    }
    return buf;
  }
951646
function serializeIntoEqualString(obj) {

        var out = '';

        _.forEach(obj, function(val, key) {
            var stringVal;

            try {
                stringVal = JSON.stringify(val, safeCycles());
            } catch (e) {
                if (safeJsonStringify) {
                    stringVal = safeJsonStringify(val);
                } else {
                    stringVal = 'unserializable! you can install ' +
                                '"safe-json"stringify" module for safer ' +
                                'stringification';
                }
            }

            out += key + '=' + stringVal + ', ';
        });
        // remove last comma
        return out.slice(0, -2);
    }
74237
function fromString (string) {
  assert.equal(typeof string, 'string')

  return from(function (size, next) {
    if (string.length <= 0) return this.push(null)

    const chunk = string.slice(0, size)
    string = string.slice(size)

    next(null, chunk)
  })
}
1084612
function stringify(value) {
  "use strict";

  if (typeof value === 'function') {
    return value.toString();
  }
  return value !== undefined ? JSON.stringify(value) : "undefined";
}
434578
def to_string(s, encoding=None, errors='strict'):
    """"""
    encoding = encoding or 'utf-8'
    if isinstance(s, bytes):
        return s.decode(encoding, errors)
    if not is_string(s):
        s = string_type(s)
    return s
1368044
function stringify(obj, replacer, spaces, cycleReplacer) {
  var myserializer = serializer(replacer, cycleReplacer), ret = JSON.stringify(obj, myserializer, spaces);
  myserializer.destroy();
  return ret;
}