Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
function fromJsonValue
import { fromJsonValue } from "https://deno.land/x/authlete_deno@v1.2.3/src/type/base_extended_enum.ts";

Convert JSON value(s) to the corresponding TExtendedEnum class(es). For example, if you pass 'CODE' (a string value) to this method, the method returns ResponseType.CODE (an instance of ResponseType class).

NOTE: this method is supposed to be used by class-transformer (the object mapper we internally use). Manual use of this method is not recommended.

Type Parameters

TExtendedEnum extends BaseExtendedEnum

Parameters

source: string | string[]

A string or string array to convert to the corresponding TExtendedEnum class or an array of the TExtendedEnum class (e.g. 'CODE').

target: { new (...args: any[]): TExtendedEnum; }

A target class to which the source is converted to. Must be a class that extends BaseExtendedEnum class (e.g. ResponseType).

Returns

An instance of the TExtendedEnum class or an array of the TExtendedEnum class. undefined is returned if the the source can't be converted to the class.