Format values with extra extended json type data.

@param {Any} value - What to wrap as a `{$<type>: <encoded>}` object.
@return {Any}
@api private
767272
function serialize(value) {
  if (Array.isArray(value) === true) {
    return serializeArray(value);
  }
  if (isObject(value) === false) {
    return serializePrimitive(value);
  }
  return serializeObject(value);
}
1370401
function serialize(value, indent) {
    "use strict";
    if (isArray(value)) {
        value = value.map(function _map(prop) {
            return isFunction(prop) ? prop.toString().replace(/\s{2,}/, '') : prop;
        });
    }
    return JSON.stringify(value, null, indent);
}
1139904
private JsonElement toElement(final Object value) {

		if (value != null) {

			if (value instanceof String) {

				return new JsonPrimitive((String)value);

			} else if (value instanceof Number) {

				return new JsonPrimitive((Number)value);

			} else if (value instanceof Boolean) {

				return new JsonPrimitive((Boolean)value);

			} else if (value.getClass().isArray()) {

				final JsonArray arr   = new JsonArray();
				final Object[] values = (Object[])value;

				for (final Object v : values) {
					arr.add(toElement(v));
				}

				return arr;

			} else {

				return new JsonPrimitive(value.toString());
			}
		}

		return JsonNull.INSTANCE;
	}
772012
function(value) {
		if (gui.Type.isString(value)) {
			if (gui.hasModule('edbml@wunderbyte.com') && value.startsWith('edbml.$get')) {
				value = window.edbml.$get(gui.KeyMaster.extractKey(value)[0]);
			} else {
				value = gui.Type.cast(value);
				if (gui.Type.isString(value)) {
					value = this._jsonvaluate(value);
				}
			}
		}
		return value;
	}
3708
def encode(cls, value):
        
        try:
            coerced = list(value)
            if coerced == value:
                return json.dumps(coerced).encode(cls._encoding)
        except TypeError:
            pass

        raise InvalidValue('not a list')
243652
function (value) {
		if (value === null) {
			return '';
		}
		if (value === undefined) {
			return '';
		}
		switch (typeof value) {
			case 'object' :
				if (value instanceof Blob) {
					return value;
				} else {
					return JSON.stringify(value);
				}
				break;
			case 'string':
				return value;
			default :
				return value;
		}
	}
27572
function (data, trans, key) {
			if (typeof data[key] !== "object") {
				throw new SyntaxError('Cannot extend a scalar value.  Transform: ' + util.getTransDescription(trans) + ' Data: ' + JSON.stringify(data));

			}

			for (var prop in trans) {
				if (typeof data[prop] === "object") {
					return extend(data[key], trans[prop], prop);
				}
				data[key][prop] = trans[prop];
			}
		}
1084612
function stringify(value) {
  "use strict";

  if (typeof value === 'function') {
    return value.toString();
  }
  return value !== undefined ? JSON.stringify(value) : "undefined";
}
818475
public Object prepare(final Object value) {
        if (value == null || value instanceof String || !stringify) {
            return value;
        } else {
            if (value instanceof Boolean) {
                return PREFIX_BOOLEAN.concat(value.toString());
            } else if (value instanceof Integer) {
                return PREFIX_INT.concat(value.toString());
            } else if (value instanceof Long) {
                return PREFIX_LONG.concat(value.toString());
            } else if (value instanceof Date) {
                return PREFIX_DATE.concat(newSdf().format((Date) value));
            } else if (value instanceof URI) {
                return PREFIX_URI.concat(value.toString());
            } else {
                return PREFIX_SB64.concat(serializationHelper.serializeToBase64((Serializable) value));
            }
        }
    }
1271570
function prettyFormat (value) {
  if (isString(value)) {
    return value
  }

  if (value instanceof Error) {
    return value.message + '\n' + value.stack
  }

  return JSON.stringify(value, null, 2)
}
614172
function serializeValue(value) {

    var type;
    if ( _.isNull(value) ) {
        type = ColumnType.Object;
    } else if ( _.isNumber(value) ) {
        type = ColumnType.Real;
    } else if ( _.isDate(value) ) {
        type = ColumnType.Date;
    } else if ( _.isBool(value) ) {
        type = ColumnType.Boolean;
    } else if ( _.isString(value) ) {
        type = ColumnType.String;
    } else if ( _.isArray(value) ) {
        type = ColumnType.Array;
    } else if ( _.isObject(value) ) {
        type = ColumnType.Object;
    } else {
        type = ColumnType.Object;
    }

    return serializeMember(value, type);
}
206628
protected function formatValue($value)
    {
        if (PHP_VERSION_ID < 50400) {
            return str_replace('\/', '/', json_encode($value));
        }

        return json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    }
659362
function(value) {
        switch (values.typeOf(value)) {
            case 'Null':
            case 'Boolean':
            case 'String':
            case 'Number':
                return value;

            case 'RegExp':
                return String(value);

            case 'Date':
            case 'Duration':
                return value.valueOf();

            case 'Filter':
                return value.source;

            case 'Array':
                return _.map(value, this.toJSONCompatible, this);

            case 'Object':
                return _.mapObject(value, this.toJSONCompatible, this);
        }
    }
1034830
function expandViewAttribValue( value ) {
    try {
        if ( isSpecial( value ) || Array.isArray( value[ 0 ] ) ) return value;
        if ( Array.isArray( value ) ) return {
            "0": value,
            "1": value[ 0 ]
        };
        return { "0": value };
    } catch ( ex ) {
        throw ex + "\n...in expandViewAttribValue: " + limitJson( value );
    }
}
882344
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }
592
function formatValue(value, fm, cc) {

    if (typeof value === 'function') {
        return formatValue(resolveFunc(value, cc), fm, cc);
    }

    const ctf = getCTF(value); // Custom Type Formatting
    if (ctf) {
        fm |= ctf.rawType ? fmFlags.raw : 0;
        return formatValue(resolveFunc(ctf.toPostgres, value), fm, cc);
    }

    const isRaw = !!(fm & fmFlags.raw);
    fm &= ~fmFlags.raw;

    switch (fm) {
        case fmFlags.alias:
            return $as.alias(value);
        case fmFlags.name:
            return $as.name(value);
        case fmFlags.json:
            return $as.json(value, isRaw);
        case fmFlags.csv:
            return $as.csv(value);
        case fmFlags.value:
            return $as.value(value);
        default:
            break;
    }

    if (isNull(value)) {
        throwIfRaw(isRaw);
        return 'null';
    }

    switch (typeof value) {
        case 'string':
            return $to.text(value, isRaw);
        case 'boolean':
            return $to.bool(value);
        case 'number':
            return $to.number(value);
        case 'symbol':
            throw new TypeError('Type Symbol has no meaning for PostgreSQL: ' + value.toString());
        default:
            if (value instanceof Date) {
                return $to.date(value, isRaw);
            }
            if (value instanceof Array) {
                return $to.array(value);
            }
            if (value instanceof Buffer) {
                return $to.buffer(value, isRaw);
            }
            return $to.json(value, isRaw);
    }
}
972588
def ConvertToWireFormat(self, value):
    """"""
    # Is it a protobuf-based value?
    if hasattr(value.__class__, "protobuf"):
      if value.__class__.protobuf:
        type_name = ("type.googleapis.com/%s" %
                     value.__class__.protobuf.__name__)
      else:
        type_name = value.__class__.__name__
      data = value.SerializeToString()
    # Is it a primitive value?
    elif hasattr(value.__class__, "data_store_type"):
      wrapper_cls = self.__class__.WRAPPER_BY_TYPE[
          value.__class__.data_store_type]
      wrapped_data = wrapper_cls()
      wrapped_data.value = value.SerializeToDataStore()

      type_name = ("type.googleapis.com/google.protobuf.%s" %
                   wrapper_cls.__name__)
      data = wrapped_data.SerializeToString()
    else:
      raise ValueError("Can't convert value %s to an protobuf.Any value." %
                       value)

    any_value = AnyValue(type_url=type_name, value=data)
    output = _SerializeEntries(_GetOrderedEntries(any_value.GetRawData()))

    return (self.encoded_tag, VarintEncode(len(output)), output)