Skip to main content

Melon.std.json.serialize(target)

Serialize an object directly into an string. Status: unstable
Returns: string

Parameters

NameTypeDescription
targetanyThe target object to be serialized

Example usage

const { serialize } = Melon.std.json;

const user = {name: "John", surname: "Doe"};
const result = serialize(user);

console.log(result);

Extra behaviors

ConditionConsequenceWorkaround
There is no error handlingAn invalid string will be returned ("")Consider using Melon.std.json.trySerialize or be sure that no invalid target will be passed as argument