function decode<T>(raw: string): T { return JSON.parse(raw) as T; } type Account = { id: string; active: boolean }; const account = decode<Account>('{"active":"yes"}'); console.log(account.id.toLowerCase());