UNPKG

formgen-react

Version:

Formula generator with JSON for react. UI Fabric controls are used for rendering

17 lines (15 loc) 572 B
import {JsonCustomConvert, JsonConverter} from "json2typescript"; import { LabelPositions } from "../../Enums"; /** * Json Converter for a LabelPorision Enum */ @JsonConverter export class LabelPositionConverter implements JsonCustomConvert<LabelPositions> { serialize(position: LabelPositions): any { return JSON.parse("[\"" + position.toString() + "\"]"); } deserialize(typeJson: any): LabelPositions { let value = JSON.stringify(typeJson[0]).replace("\"","").replace("\"",""); return LabelPositions[value]; } }