Skip to main content

Melon.std.json.tryDeserialize<T>(target)

Tries to deserialize an string into an object of the type T. Status: stable
Returns: Result<TError, TValue>

Parameters

NameTypeDescription
targetstringThe target object to be serialized

Example usage

const { tryDeserialize } = Melon.std.json;

interface User {
name: string;
surname: string;
}

const userJson = `{name: "John", surname: "Doe"}`;
const result = tryDeserialize<User>(userJson);
result.join();

result.match(_ => {}, console.log);

Extra behaviors