添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
坚韧的马克杯
·
“618”深度观察|拼多多、阿里、京东及抖音 ...
·
2 天前
·
不羁的仙人掌
·
Implementing React ...
·
1 周前
·
调皮的遥控器
·
平安传无删减完整版(西风紧)-平安传无删减完 ...
·
3 月前
·
率性的羽毛球
·
沉浸视觉体验“镜”收眼底 佳能推出3D ...
·
6 月前
·
从容的脆皮肠
·
比亚迪唐方向盘价格报价行情 - 京东
·
1 年前
·
link管理
›
掌握 TypeScript 中类型安全的 JSON 序列化 | HackerNoon
https://hackernoon.com/zh/%E6%8E%8C%E6%8F%A1-TypeScript-%E4%B8%AD%E7%B1%BB%E5%9E%8B%E5%AE%89%E5%85%A8%E7%9A%84-json-%E5%BA%8F%E5%88%97%E5%8C%96
讲道义的大海
5 月前
</noscript><div id="__next" data-reactroot=""><div class="sc-2c5f548e-0 bSTUPm"><header class="sc-82c061cb-0 gKEHPb"><div class="mainNav" style="background:;background-image:"><div class="left-portion"><div class="search-container active"><div class="input-holder"><div class="ais-SearchBox"><form novalidate="" class="ais-SearchBox-form" action="" role="search"><input type="search" placeholder="Discover Anything" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" required="" maxlength="512" value="" class="ais-SearchBox-input"/><button type="submit" title="Submit your search query." class="ais-SearchBox-submit"><svg class="ais-SearchBox-submitIcon" xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewbox="0 0 40 40"><path d="M26.804 29.01c-2.832 2.34-6.465 3.746-10.426 3.746C7.333 32.756 0 25.424 0 16.378 0 7.333 7.333 0 16.378 0c9.046 0 16.378 7.333 16.378 16.378 0 3.96-1.406 7.594-3.746 10.426l10.534 10.534c.607.607.61 1.59-.004 2.202-.61.61-1.597.61-2.202.004L26.804 29.01zm-10.426.627c7.323 0 13.26-5.936 13.26-13.26 0-7.32-5.937-13.257-13.26-13.257C9.056 3.12 3.12 9.056 3.12 16.378c0 7.323 5.936 13.26 13.258 13.26z"/></svg></button><button type="reset" title="Clear the search query." class="ais-SearchBox-reset" hidden=""><svg class="ais-SearchBox-resetIcon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 20 20" width="10" height="10"><path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"/></svg></button></form></div><img src="https://hackernoon.imgix.net/search-new.png?w=19&h=19" class="search" alt="Search icon" width="19" height="19"/></div></div></div><a class="logo" href="/"><span class="desktop" style="background-color:;padding:5px;border-radius:5px"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27205%27%20height=%2730%27/%3e"/></span><img alt="Hackernoon logo" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Hackernoon logo" srcset="https://hackernoon.imgix.net/hn-logo.png?auto=format&fit=max&w=256 1x, https://hackernoon.imgix.net/hn-logo.png?auto=format&fit=max&w=640 2x" src="https://hackernoon.imgix.net/hn-logo.png?auto=format&fit=max&w=640" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></span><span class="mobile"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2737%27%20height=%2740%27/%3e"/></span><img alt="Hackernoon logo" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Hackernoon logo" srcset="https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=48 1x, https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=96 2x" src="https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=96" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></span></a><div class="right-portion"><div style="width:fit-content" class="sc-82c061cb-1 bdgrFM"><a style="color:#003b00;border-color:#003b00;background-color:#88ff88;border-radius:5px" href="/reader-boot" class="sc-b3d23cc4-0 biyRsJ">Read</a><a style="color:#003b00;border-color:#003b00;background-color:#88ff88;border-radius:5px;margin-right:2rem" href="https://app.hackernoon.com/new" class="sc-b3d23cc4-0 biyRsJ">Write</a></div><div><img width="35" height="35" src="https://hackernoon.imgix.net/unread-bell.png?w=40" style="vertical-align:middle" alt="see notifications" class="sc-10ad50bb-0 eEPpJj"/><div class="sc-10ad50bb-1 bhpfbh"><div class="header">Notifications</div><div class="content"/><div style="display:flex"><div class="more">see <!-- --> more</div></div></div></div><div class="sc-dd1bca92-0 gJMfFs"><div data-focus-guard="true" tabindex="-1" style="width:1px;height:0px;padding:0;overflow:hidden;position:fixed;top:1px;left:1px"/><div data-focus-lock-disabled="disabled"><button aria-label="Toggle menu" aria-expanded="false" aria-controls="main-menu" class="sc-14b24a79-0 jxzHai"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 22 20" width="22" style="fill:"><path style="fill:" d="M21 9h1v2h-1v1H1v-1H0V9h1V8h20v1zM21 17h1v2h-1v1H1v-1H0v-2h1v-1h20v1zM22 1v2h-1v1H1V3H0V1h1V0h20v1h1z"/></svg></button><div aria-hidden="true" style="background-color:" class="sc-16ad823d-0 cCegnu"><div class="mobile-header"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e"/></span><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="hackernoon-logo" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img srcset="https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=96 1x, https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=96 2x" src="https://hackernoon.imgix.net/hn-icon.png?auto=format&fit=max&w=96" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="hackernoon-logo" loading="lazy"/></noscript></span><div class="mobile-header-left"><a href="https://app.hackernoon.com/signup" class="mobile-auth">LOGIN / SIGNUP</a><img class="close-nav-img" src="https://hackernoon.imgix.net/icons/SVG/awesome/Window%20Close.svg"/></div></div><div class="sc-16ad823d-1 jDBweW"/></div></div><div data-focus-guard="true" tabindex="-1" style="width:1px;height:0px;padding:0;overflow:hidden;position:fixed;top:1px;left:1px"/></div></div></div><div class="sc-a849a22-0 lpfrxH subNav" style="background-color:;color:"><ul style="background-color:" class="sc-fde74a6a-0 kHVjkh"/></div><div><div style="background:;color:" class="sc-507e8eeb-0 fNNkCO"><a class="logo" href="/"><img src="/hn-logo.png" alt="Hackernoon logo"/></a><a style="color:" class="daLink" target="_blank" rel="sponsored"><span style="color:;display:flex;align-items:center;background:;padding:0 10px;border-radius:5px"/></a><div class="colorPickerIcon"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2725%27%20height=%2725%27/%3e"/></span><img alt="paint-brush" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="paint-brush" srcset="https://hackernoon.imgix.net/brush2.png?w=25&auto=format&fit=max 1x, https://hackernoon.imgix.net/brush2.png?w=25&auto=format&fit=max 2x" src="https://hackernoon.imgix.net/brush2.png?w=25&auto=format&fit=max" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div></div></div><div class="sc-9de06f04-0 lfEhlG story-nav show"><div class="title"><span class="story-title">掌握 TypeScript 中类型安全的 JSON 序列化</span><span class="by"> <!-- -->经过</span><a class="profile" href="/u/nodge">@<!-- -->nodge</a><div class="profile-img"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e"/></span><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img srcset="https://cdn.hackernoon.com/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?auto=format&fit=max&w=32 1x, https://cdn.hackernoon.com/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?auto=format&fit=max&w=64 2x" src="https://cdn.hackernoon.com/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?auto=format&fit=max&w=64" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div></div><div class="sharing"/></div></header><div style="position:fixed;z-index:9999;top:16px;left:16px;right:16px;bottom:16px;pointer-events:none"/><main class="sc-2c5f548e-1 ObBbx"><div class="sc-d7dc08c8-0 cWxOGs"><div class="sc-eddc3d13-0 iEEOIy"><div class="metaContainer desktop-no-show"><div class="sc-eddc3d13-4 eNSifU"><div class="sc-eddc3d13-3 iLa-diI"><span class="story-stat"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 22 22" width="22" style="width:14px;fill:darkgray"><path style="width:14px;fill:darkgray" d="M22 7v2h-1v1h-1v1h-1v1h-1v1h-1v5h1v4h-2v-1h-2v-1h-2v-1h-2v1H8v1H6v1H4v-4h1v-5H4v-1H3v-1H2v-1H1V9H0V7h7V5h1V3h1V1h1V0h2v1h1v2h1v2h1v2h7z"/></svg> <!-- -->9,721<!-- --> <!-- -->讀數</span></div></div></div><div class="story-topLine"><div class="story-stats"><span class="story-stat mobile-no-show"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 22 22" width="22" style="width:14px"><path style="width:14px" d="M22 7v2h-1v1h-1v1h-1v1h-1v1h-1v5h1v4h-2v-1h-2v-1h-2v-1h-2v1H8v1H6v1H4v-4h1v-5H4v-1H3v-1H2v-1H1V9H0V7h7V5h1V3h1V1h1V0h2v1h1v2h1v2h1v2h7z"/></svg> <!-- -->9,721<!-- --> <!-- -->讀數</span></div><div class="story-admin"/></div><h1 class="story-title" style="text-align:center">掌握 TypeScript 中类型安全的 JSON 序列化</h1><div class="title-bottom"><div class="title-bottom-left"><span class="header-handle " data-tip="true" data-for="story-author" aria-label="bookmark story" data-delay-hide="1000"><span> 经过 </span><a> <!-- -->Maksim Zemskov</a></span><span class="divider-bullet"/><span class="reading-time">11<!-- -->m</span><span class="divider-bullet"/><span class="published-date">2024/02/26</span></div><div class="title-bottom-right"><div style="flex-shrink:0"><span style="display:flex;cursor:pointer" data-tip="true" data-for="terminal-view"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="Read on Terminal Reader" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Read on Terminal Reader" srcset="https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></span></div></div></div><div class="divider-line"/><div class="tldr-langs"><div class="sc-eddc3d13-4 eNSifU"><div class="sc-eddc3d13-3 iLa-diI"><div class="sc-eddc3d13-1 krRzTw"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2750%27%20height=%2715%27/%3e"/></span><img alt="Open TLDR" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="tldr-logo" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Open TLDR" srcset="https://hackernoon.imgix.net/tl;dr-dark.png?auto=format&fit=max&w=64 1x, https://hackernoon.imgix.net/tl;dr-dark.png?auto=format&fit=max&w=128 2x" src="https://hackernoon.imgix.net/tl;dr-dark.png?auto=format&fit=max&w=128" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="tldr-logo" loading="lazy"/></noscript></span><img src="https://hackernoon.imgix.net/arrow-dark.png" alt="tldt arrow" width="12px" height="12px" class="tldr-arrow "/></div></div></div><div class="sc-eddc3d13-2 imQnli"><div class="sc-eddc3d13-6 jEbEgr"><a class="lang " data-tip="true" data-for="en-lang" href="/mastering-type-safe-json-serialization-in-typescript"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="en-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="en-flag" srcset="https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>EN</a><a class="lang " data-tip="true" data-for="ru-lang" href="/ru/%D0%BE%D1%81%D0%B2%D0%BE%D0%B5%D0%BD%D0%B8%D0%B5-%D1%82%D0%B8%D0%BF%D0%BE%D0%B1%D0%B5%D0%B7%D0%BE%D0%BF%D0%B0%D1%81%D0%BD%D0%BE%D0%B9-%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-JSON-%D0%B2-%D0%BC%D0%B0%D1%88%D0%B8%D0%BD%D0%BE%D0%BF%D0%B8%D1%81%D0%BD%D0%BE%D0%BC-%D1%82%D0%B5%D0%BA%D1%81%D1%82%D0%B5"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="ru-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="ru-flag" srcset="https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>RU</a><a class="lang " data-tip="true" data-for="tr-lang" href="/tr/typescript'te-tip-g%C3%BCvenli-json-serile%C5%9Ftirmesine-hakim-olma"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="tr-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="tr-flag" srcset="https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>TR</a><a class="lang " data-tip="true" data-for="ko-lang" href="/ko/TypeScript%EC%97%90%EC%84%9C-%EC%9C%A0%ED%98%95-%EC%95%88%EC%A0%84-json-%EC%A7%81%EB%A0%AC%ED%99%94-%EB%A7%88%EC%8A%A4%ED%84%B0%EB%A7%81"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="ko-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="ko-flag" srcset="https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>KO</a><a class="lang " data-tip="true" data-for="de-lang" href="/de/Beherrschen-der-typsicheren-JSON-Serialisierung-in-Typoskript"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="de-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="de-flag" srcset="https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>DE</a><a class="lang " data-tip="true" data-for="bn-lang" href="/bn/%E0%A6%9F%E0%A6%BE%E0%A6%87%E0%A6%AA%E0%A6%B8%E0%A7%8D%E0%A6%95%E0%A7%8D%E0%A6%B0%E0%A6%BF%E0%A6%AA%E0%A7%8D%E0%A6%9F%E0%A7%87-%E0%A6%AE%E0%A6%BE%E0%A6%B8%E0%A7%8D%E0%A6%9F%E0%A6%BE%E0%A6%B0%E0%A6%BF%E0%A6%82-%E0%A6%9F%E0%A6%BE%E0%A6%87%E0%A6%AA-%E0%A6%A8%E0%A6%BF%E0%A6%B0%E0%A6%BE%E0%A6%AA%E0%A6%A6-json-%E0%A6%B8%E0%A6%BF%E0%A6%B0%E0%A6%BF%E0%A6%AF%E0%A6%BC%E0%A6%BE%E0%A6%B2%E0%A6%BE%E0%A6%87%E0%A6%9C%E0%A7%87%E0%A6%B6%E0%A6%A8"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="bn-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="bn-flag" srcset="https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>BN</a><a class="lang " data-tip="true" data-for="es-lang" href="/es/masterizacion-tipo-segura-json-serializacion-en-mecanografiado"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="es-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="es-flag" srcset="https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>ES</a><a class="lang " data-tip="true" data-for="hi-lang" href="/hi/%E0%A4%9F%E0%A4%BE%E0%A4%87%E0%A4%AA%E0%A4%B8%E0%A5%8D%E0%A4%95%E0%A5%8D%E0%A4%B0%E0%A4%BF%E0%A4%AA%E0%A5%8D%E0%A4%9F-%E0%A4%AE%E0%A5%87%E0%A4%82-%E0%A4%B8%E0%A5%81%E0%A4%B0%E0%A4%95%E0%A5%8D%E0%A4%B7%E0%A4%BF%E0%A4%A4-JSON-%E0%A4%95%E0%A5%8D%E0%A4%B0%E0%A4%AE%E0%A4%BE%E0%A4%82%E0%A4%95%E0%A4%A8-%E0%A4%AE%E0%A5%87%E0%A4%82-%E0%A4%AE%E0%A4%B9%E0%A4%BE%E0%A4%B0%E0%A4%A4-%E0%A4%B9%E0%A4%BE%E0%A4%B8%E0%A4%BF%E0%A4%B2-%E0%A4%95%E0%A4%B0%E0%A4%A8%E0%A4%BE"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="hi-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hi-flag" srcset="https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>HI</a><a class="lang " data-tip="true" data-for="vi-lang" href="/vi/l%C3%A0m-ch%E1%BB%A7-ki%E1%BB%83u-tu%E1%BA%A7n-t%E1%BB%B1-h%C3%B3a-json-an-to%C3%A0n-trong-b%E1%BA%A3n-th%E1%BA%A3o"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="vi-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="vi-flag" srcset="https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>VI</a><a class="lang " data-tip="true" data-for="fr-lang" href="/fr/ma%C3%AEtriser-la-s%C3%A9rialisation-json-s%C3%A9curis%C3%A9e-de-type-en-dactylographi%C3%A9"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="fr-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="fr-flag" srcset="https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>FR</a><a class="lang " data-tip="true" data-for="pt-lang" href="/pt/dominando-a-serializa%C3%A7%C3%A3o-json-segura-do-tipo-em-TypeScript"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="pt-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="pt-flag" srcset="https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>PT</a><a class="lang " data-tip="true" data-for="ja-lang" href="/ja/TypeScript-%E3%81%A7%E3%81%AE%E3%82%BF%E3%82%A4%E3%83%97-%E3%82%BB%E3%83%BC%E3%83%95%E3%81%AA-JSON-%E3%82%B7%E3%83%AA%E3%82%A2%E3%83%AB%E5%8C%96%E3%82%92%E3%83%9E%E3%82%B9%E3%82%BF%E3%83%BC%E3%81%99%E3%82%8B"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="ja-flag" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="ja-flag" srcset="https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=16 1x, https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=32 2x" src="https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span>JA</a></div><div class="sc-eddc3d13-7 coRSOd"><span class="lang selected-lang"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="flag" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img srcset="https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="flag" loading="lazy"/></noscript></span><strong>ZH</strong></span></div></div></div><div class="tldr-no-show"><h2>太長; 讀書</h2>本文探讨了使用 JSON 格式时在 TypeScript 中进行数据序列化的挑战。它特别关注 JSON.stringify 和 JSON.parse 函数的缺点。为了解决这些问题,它建议使用 JSONCompatible 类型来验证类型 T 是否可以安全地序列化为 JSON。此外,它还推荐使用 Superstruct 库来安全地从 JSON 进行反序列化。此方法提高了类型安全性并支持开发过程中的错误检测。</div></div><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%271200%27%20height=%27600%27/%3e"/></span><img alt="featured image - 掌握 TypeScript 中类型安全的 JSON 序列化" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="image-container feat" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="featured image - 掌握 TypeScript 中类型安全的 JSON 序列化" srcset="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-86a3wwp.jpeg?auto=format&fit=max&w=1200 1x, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-86a3wwp.jpeg?auto=format&fit=max&w=3840 2x" src="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-86a3wwp.jpeg?auto=format&fit=max&w=3840" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="image-container feat" loading="lazy"/></noscript></span><div style="grid-column:1 / -1"/><div class="sc-6d048d67-0 hSAajO profile"><div class="sc-6d048d67-1 lhMlhT"><div class="profileImageContainer "><span style="box-sizing:border-box;display:block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;top:0;left:0;bottom:0;right:0"><img data-for="author-tooltip" data-tip="true" data-delay-hide="200" alt="Maksim Zemskov HackerNoon profile picture" href="/u/nodge" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="fill" class="profileImage " style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;object-fit:cover"/><noscript><img data-for="author-tooltip" data-tip="true" data-delay-hide="200" alt="Maksim Zemskov HackerNoon profile picture" href="/u/nodge" sizes="100vw" srcset="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 640w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 750w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 828w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 1080w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 1200w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 1920w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 2048w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max 3840w" src="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=100&auto=format&fit=max" decoding="async" data-nimg="fill" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;object-fit:cover" class="profileImage " loading="lazy"/></noscript></span></div><div class="sc-bcdf6571-0 fxBXjb"><div data-for="cred-tooltip" data-tip="[object Object],[object Object],[object Object]" data-delay-hide="200" class="container"><div class="cred-item"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="0-item" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="0-item" srcset="https://cdn.hackernoon.com/images/img-b8133ik.png?auto=format&fit=max&w=16 1x, https://cdn.hackernoon.com/images/img-b8133ik.png?auto=format&fit=max&w=32 2x" src="https://cdn.hackernoon.com/images/img-b8133ik.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div><div class="cred-item"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="1-item" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="1-item" srcset="https://cdn.hackernoon.com/images/img-5p03rto.png?auto=format&fit=max&w=16 1x, https://cdn.hackernoon.com/images/img-5p03rto.png?auto=format&fit=max&w=32 2x" src="https://cdn.hackernoon.com/images/img-5p03rto.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div><div class="cred-item"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2715%27%20height=%2715%27/%3e"/></span><img alt="2-item" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="2-item" srcset="https://cdn.hackernoon.com/images/img-w003rvs.png?auto=format&fit=max&w=16 1x, https://cdn.hackernoon.com/images/img-w003rvs.png?auto=format&fit=max&w=32 2x" src="https://cdn.hackernoon.com/images/img-w003rvs.png?auto=format&fit=max&w=32" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div></div></div></div></div><div><div class="sc-394e77f1-0 hrzfuA"><div><p class="line-space"> <br/> </p><p>几乎每个<a href="https://hackernoon.com/66-stories-to-learn-about-web-app-development?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">Web 应用程序</a>都需要数据序列化。这种需求会在以下情况下出现:</p><p class="line-space"> <br/> </p><ul><li>通过网络传输数据(例如 HTTP 请求、WebSockets)</li><li>在 HTML 中嵌入数据(例如,用于水合作用)</li><li>将数据存储在持久存储中(例如 LocalStorage)</li><li>在进程之间共享数据(例如 Web Worker 或 postMessage)</li></ul><p class="line-space"> <br/> </p><p>在许多情况下,数据丢失或损坏可能会导致严重后果,因此必须提供一种方便且安全的序列化机制,以帮助在开发阶段检测尽可能多的错误。出于这些目的,在开发过程中使用<a href="https://hackernoon.com/57-stories-to-learn-about-json?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">JSON</a>作为数据传输格式并使用 TypeScript 进行静态代码检查会很方便。</p><p class="line-space"> <br/> </p><p> TypeScript 是 JavaScript 的超集,它应该能够无缝使用<code>JSON.stringify</code>和<code>JSON.parse</code>等函数,对吗?事实证明,尽管 TypeScript 有这么多好处,但它并不自然地理解 JSON 是什么以及哪些数据类型可以安全地序列化和反序列化为 JSON。</p><p class="line-space"> <br/> </p><p>让我们用一个例子来说明这一点。</p><p class="line-space"> <br/> </p><h2> TypeScript 中 JSON 的问题</h2><p>例如,考虑一个将一些数据保存到 LocalStorage 的函数。由于LocalStorage无法存储对象,因此我们这里使用JSON序列化:</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">interface PostComment { authorId: string; text: string; updatedAt: Date; } function saveComment(comment: PostComment) { const serializedComment = JSON.stringify(comment); localStorage.setItem('draft', serializedComment); }</code></pre><p class="line-space"> <br/> </p><p>我们还需要一个函数来从 LocalStorage 检索数据。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">function restoreComment(): PostComment | undefined { const text = localStorage.getItem('draft'); return text ? JSON.parse(text) : undefined; }</code></pre><p class="line-space"> <br/> </p><p>这段代码有什么问题?第一个问题是,在恢复评论时,我们会得到一个<code>string</code>类型,而不是<code>updatedAt</code>字段的<code>Date</code>类型。</p><p class="line-space"> <br/> </p><p>发生这种情况是因为 JSON 只有四种基本数据类型( <code>null</code> 、 <code>string</code> 、 <code>number</code> 、 <code>boolean</code> )以及数组和对象。无法在 JSON 中保存<code>Date</code>对象,以及 JavaScript 中的其他对象:函数、Map、Set 等。</p><p class="line-space"> <br/> </p><p>当<code>JSON.stringify</code>遇到无法以 JSON 格式表示的值时,就会发生类型转换。对于<code>Date</code>对象,我们得到一个字符串,因为<code>Date</code>对象实现了<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">toJson()</a>方法,该方法返回一个字符串而不是<code>Date</code>对象。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">const date = new Date('August 19, 1975 23:15:30 UTC'); const jsonDate = date.toJSON(); console.log(jsonDate); // Expected output: "1975-08-19T23:15:30.000Z" const isEqual = date.toJSON() === JSON.stringify(date); console.log(isEqual); // Expected output: true</code></pre><p class="line-space"> <br/> </p><p>第二个问题是<code>saveComment</code>函数返回<code>PostComment</code>类型,其中日期字段的类型为<code>Date</code> 。但我们已经知道,我们将收到<code>string</code>类型,而不是<code>Date</code> 。 TypeScript 可以帮助我们找到这个错误,但为什么不呢?</p><p class="line-space"> <br/> </p><p>事实证明,在 TypeScript 的标准库中, <code>JSON.parse</code>函数的类型为<code>(text: string) => any</code> 。由于使用了<code>any</code> ,类型检查基本上被禁用。在我们的示例中,TypeScript 只是接受了我们的说法,即该函数将返回包含<code>Date</code>对象的<code>PostComment</code> 。</p><p class="line-space"> <br/> </p><p>这种 TypeScript 行为既不方便又不安全。如果我们尝试将字符串视为<code>Date</code>对象,我们的应用程序可能会崩溃。例如,如果我们调用<code>comment.updatedAt.toLocaleDateString()</code>它可能会中断。</p><p class="line-space"> <br/> </p><p>事实上,在我们的小示例中,我们可以简单地将<code>Date</code>对象替换为数字时间戳,这对于 JSON 序列化非常有效。然而,在实际应用中,数据对象可能很广泛,类型可以在多个位置定义,并且在开发过程中识别此类错误可能是一项具有挑战性的任务。</p><p class="line-space"> <br/> </p><p>如果我们可以增强 TypeScript 对 JSON 的理解会怎么样?</p><p class="line-space"> <br/> </p><h2>处理序列化</h2><p>首先,让我们弄清楚如何让 TypeScript 了解哪些数据类型可以安全地序列化为 JSON。假设我们要创建一个函数<code>safeJsonStringify</code> ,其中 TypeScript 将检查输入数据格式以确保它是 JSON 可序列化的。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">function safeJsonStringify(data: JSONValue) { return JSON.stringify(data); }</code></pre><p class="line-space"> <br/> </p><p>在这个函数中,最重要的部分是<code>JSONValue</code>类型,它代表了所有可以用JSON格式表示的可能值。实现非常简单:</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">type JSONPrimitive = string | number | boolean | null | undefined; type JSONValue = JSONPrimitive | JSONValue[] | { [key: string]: JSONValue; };</code></pre><p class="line-space"> <br/> </p><p>首先,我们定义<code>JSONPrimitive</code>类型,它描述了所有原始 JSON 数据类型。我们还包含<code>undefined</code>类型,因为序列化时,具有<code>undefined</code>值的键将被省略。在反序列化期间,这些键根本不会出现在对象中,这在大多数情况下是相同的。</p><p class="line-space"> <br/> </p><p>接下来,我们描述<code>JSONValue</code>类型。此类型使用 TypeScript 描述递归类型的能力,递归类型是引用自身的类型。这里, <code>JSONValue</code>可以是<code>JSONPrimitive</code> 、 <code>JSONValue</code>数组,也可以是所有值都是<code>JSONValue</code>类型的对象。因此,这种<code>JSONValue</code>类型的变量可以包含无限嵌套的数组和对象。还将检查其中的值是否与 JSON 格式兼容。</p><p class="line-space"> <br/> </p><p>现在我们可以使用以下示例来测试<code>safeJsonStringify</code>函数:</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">// No errors safeJsonStringify({ updatedAt: Date.now() }); // Yields an error: // Argument of type '{ updatedAt: Date; }' is not assignable to parameter of type 'JSONValue'. // Types of property 'updatedAt' are incompatible. // Type 'Date' is not assignable to type 'JSONValue'. safeJsonStringify({ updatedAt: new Date(); });</code></pre><p class="line-space"> <br/> </p><p>一切似乎都运转正常。该函数允许我们将日期作为数字传递,但如果我们传递<code>Date</code>对象,则会产生错误。</p><p class="line-space"> <br/> </p><p>但让我们考虑一个更实际的示例,其中传递给函数的数据存储在变量中并具有所描述的类型。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">interface PostComment { authorId: string; text: string; updatedAt: number; }; const comment: PostComment = {...}; // Yields an error: // Argument of type 'PostComment' is not assignable to parameter of type 'JSONValue'. // Type 'PostComment' is not assignable to type '{ [key: string]: JSONValue; }'. // Index signature for type 'string' is missing in type 'PostComment'. safeJsonStringify(comment);</code></pre><p class="line-space"> <br/> </p><p>现在,事情变得有点棘手。 TypeScript 不允许我们将<code>PostComment</code>类型的变量分配给<code>JSONValue</code>类型的函数参数,因为“‘PostComment’类型中缺少类型‘string’的索引签名”。</p><p class="line-space"> <br/> </p><p>那么,什么是索引签名以及为什么缺少索引签名?还记得我们如何描述可以序列化为 JSON 格式的对象吗?</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">type JSONValue = { [key: string]: JSONValue; };</code></pre><p class="line-space"> <br/> </p><p>在本例中, <code>[key: string]</code>是索引签名。它的意思是“这个对象可以有任何字符串形式的键,其值具有<code>JSONValue</code>类型”。那么,我们需要为<code>PostComment</code>类型添加索引签名,对吗?</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">interface PostComment { authorId: string; text: string; updatedAt: number; // Don't do this: [key: string]: JSONValue; };</code></pre><p class="line-space"> <br/> </p><p>这样做意味着注释可以包含任何任意字段,这通常不是在应用程序中定义数据类型时所需的结果。</p><p class="line-space"> <br/> </p><p>索引签名问题的真正解决方案来自<a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">映射类型</a>,它允许递归地迭代字段,即使对于没有定义索引签名的类型也是如此。与泛型相结合,此功能允许将任何数据类型<code>T</code>转换为另一种类型<code>JSONCompatible<T></code> ,该类型与 JSON 格式兼容。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">type JSONCompatible<T> = unknown extends T ? never : { [P in keyof T]: T[P] extends JSONValue ? T[P] : T[P] extends NotAssignableToJson ? never : JSONCompatible<T[P]>; }; type NotAssignableToJson = | bigint | symbol | Function;</code></pre><p class="line-space"> <br/> </p><p> <code>JSONCompatible<T></code>类型是一种映射类型,用于检查给定类型<code>T</code>是否可以安全地序列化为 JSON。它通过迭代类型<code>T</code>中的每个属性并执行以下操作来实现此目的:</p><p class="line-space"> <br/> </p><ol><li> <code>T[P] extends JSONValue ? T[P] : ...</code>条件类型验证属性的类型是否与<code>JSONValue</code>类型兼容,确保它可以安全地转换为 JSON。在这种情况下,属性的类型保持不变。</li><li> <code>T[P] extends NotAssignableToJson ? never : ...</code>条件类型验证属性的类型是否不可分配给 JSON。在这种情况下,属性的类型将转换为<code>never</code> ,从而有效地将属性从最终类型中过滤掉。</li><li>如果这两个条件都不满足,则递归检查类型,直到得出结论。这样,即使类型没有索引签名,它也可以工作。</li></ol><p class="line-space"> <br/> </p><p> <code>unknown extends T ? never :...</code>开头的检查用于防止<code>unknown</code>类型转换为空对象类型<code>{}</code> ,它本质上相当于<code>any</code>类型。</p><p class="line-space"> <br/> </p><p>另一个有趣的方面是<code>NotAssignableToJson</code>类型。它由两个 TypeScript 原语(bigint 和 symbol)和<code>Function</code>类型组成,Function 类型描述了任何可能的函数。 <code>Function</code>类型对于过滤掉任何不可分配给 JSON 的值至关重要。这是因为 JavaScript 中的任何复杂对象都是基于 Object 类型的,并且在其原型链中至少有一个函数(例如<code>toString()</code> )。 <code>JSONCompatible</code>类型会迭代所有这些函数,因此检查函数足以过滤掉任何不可序列化为 JSON 的内容。</p><p class="line-space"> <br/> </p><p>现在,让我们在序列化函数中使用此类型:</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">function safeJsonStringify<T>(data: JSONCompatible<T>) { return JSON.stringify(data); }</code></pre><p class="line-space"> <br/> </p><p>现在,该函数使用通用参数<code>T</code>并接受<code>JSONCompatible<T></code>参数。这意味着它采用<code>T</code>类型的参数<code>data</code> ,该类型应该是 JSON 兼容的类型。现在我们可以使用没有索引签名的数据类型的函数。</p><p class="line-space"> <br/> </p><p>该函数现在使用从<code>JSONCompatible<T></code>类型扩展的通用参数<code>T</code>这意味着它接受<code>T</code>类型的参数<code>data</code> ,该类型应该是 JSON 兼容的类型。因此,我们可以将该函数用于缺少索引签名的数据类型。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">interface PostComment { authorId: string; text: string; updatedAt: number; } function saveComment(comment: PostComment) { const serializedComment = safeJsonStringify(comment); localStorage.setItem('draft', serializedComment); }</code></pre><p class="line-space"> <br/> </p><p>只要需要 JSON 序列化,例如通过网络传输数据、在 HTML 中嵌入数据、将数据存储在 localStorage 中、在工作程序之间传输数据等,都可以使用此方法。此外,当严格<code>toJsonValue</code>对象没有需要将索引签名分配给<code>JSONValue</code>类型的变量。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">function toJsonValue<T>(value: JSONCompatible<T>): JSONValue { return value; } const comment: PostComment = {...}; const data: JSONValue = { comment: toJsonValue(comment) };</code></pre><p class="line-space"> <br/> </p><p>在此示例中,使用<code>toJsonValue</code>让我们绕过与<code>PostComment</code>类型中缺少索引签名相关的错误。</p><p class="line-space"> <br/> </p><h2>处理反序列化</h2><p>当涉及到反序列化时,挑战既简单又复杂,因为它涉及对接收数据格式的静态分析检查和运行时检查。</p><p class="line-space"> <br/> </p><p>从 TypeScript 类型系统的角度来看,挑战非常简单。让我们考虑以下示例:</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">function safeJsonParse(text: string) { return JSON.parse(text) as unknown; } const data = JSON.parse(text); // ^? unknown</code></pre><p class="line-space"> <br/> </p><p>在本例中,我们用<code>unknown</code>类型替换<code>any</code>返回类型。为什么选择<code>unknown</code> ?本质上,JSON 字符串可以包含任何内容,而不仅仅是我们期望接收的数据。例如,数据格式可能会在不同的应用程序版本之间发生变化,或者应用程序的另一部分可能会将数据写入相同的 LocalStorage 键。所以, <code>unknown</code>才是最安全、最精准的选择。</p><p class="line-space"> <br/> </p><p>然而,使用<code>unknown</code>类型不如仅仅指定所需的数据类型方便。除了类型转换之外,还有多种方法可以将<code>unknown</code>类型转换为所需的数据类型。其中一种方法是利用<a href="https://docs.superstructjs.org/?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">Superstruct</a>库在运行时验证数据,并在数据无效时抛出详细错误。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">import { create, object, number, string } from 'superstruct'; const PostComment = object({ authorId: string(), text: string(), updatedAt: number(), }); // Note: we no longer need to manually specify the return type function restoreDraft() { const text = localStorage.getItem('draft'); return text ? create(JSON.parse(text), PostComment) : undefined; }</code></pre><p class="line-space"> <br/> </p><p>在这里, <code>create</code>函数充当类型保护,将类型<a href="https://www.typescriptlang.org/docs/handbook/2/narrowing.html?ref=hackernoon.com#using-type-predicates" target="_blank" rel="noopener noreferrer ugc">缩小</a>到所需的<code>Comment</code>接口。因此,我们不再需要手动指定返回类型。</p><p class="line-space"> <br/> </p><p>实现安全的反序列化选项只是故事的一半。同样重要的是,在处理项目中的下一个任务时不要忘记使用它。如果一个大型团队正在处理该项目,这将变得尤其具有挑战性,因为确保遵循所有协议和最佳实践可能很困难。</p><p class="line-space"> <br/> </p><p> <a href="https://typescript-eslint.io/?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">Typescript-eslint</a>可以帮助完成这项任务。该工具有助于识别<code>any</code>不安全使用的所有实例。具体来说,可以找到<code>JSON.parse</code>的所有用法,并且可以确保接收到的数据的格式得到检查。有关摆脱代码库中的<code>any</code>类型的更多信息,请参阅<a href="https://hackernoon.com/making-typescript-truly-strongly-typed?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">《使 TypeScript 真正成为“强类型”》</a>一文。</p><p class="line-space"> <br/> </p><h2>结论</h2><p>以下是旨在帮助安全 JSON 序列化和反序列化的最终实用函数和类型。您可以在准备好的<a href="https://www.typescriptlang.org/play?target=99&useUnknownInCatchVariables=true&ts=5.3.3&ref=hackernoon.com#code/C4TwDgpgBAUgygeQHIAUBOBLAth4GBu0AvFAM7CYB2A5lAD5SUCuWARhGvVKwPY8A2EAIaUuzfvy5NKAEwgAzDJQgyA3ACh1oSLERIAakP5Niu5Omy4C0BvGSHjEANoBdLgG91Ub1CcBrCBAALjIKJWoXELsDIxMNAF8NLXBoJB5gAEFSUgxqSiFWQQAVHhhSHlESLx8GVlylYChq7wZSEDYBJp8uADFpAGM8CqTtaGiAYR4sMCE8QogAHiKAPigSaT9KHgB3UQgAD2AIWVIoIqgAfkYIQk4Qz26nFCglKACQHnkzyK7unyKnm4DkcTmYYo5LmdAVAQs0-gCUEDDscZKc0plsrl8vMSmUKpDlLcYb8-mDJtNZhh5ktAcsEiMUmcIOQEKwAFYQQZrMlTGZzQQLdxQeR8EIAclYQjQYtUUBkswgIQAIgqoPE6eoAPSanwAPQumlGTPIFhweEI3ImvMp1PIVGoGu1eoNyR0RWZwAAqpRNjtKjyKfzFhstrtHTrvPrDYz3eRvb7dugeGBLXpyXyqQKhUIQiG-Wrw87NE75AMhqJSEJ5BA8ZQ4GEaBh5CAABTy4A5sEOEwASignid3TQEGATDQomiADo7eEm6320IexonfFNKXKIMMPjK9Xa-X7XOllBgSjTlbA5nFitlm3Zp2in2Hj5h6Px2Dpw3qHPbx2l+pV+oO41uUdaft+T7eCKPDipK0oADT-n+Wo6kBe5gc2LYDhGPhMGA7YqBkwAhMo2xQCqRwtj2yFqkhDQcPIQj9NAKA8OQ5JYMcjQQVAQhMMAAAWPBoAAkjIIQzjQGgAJBHIc4mfho3S4fhMiEcRLDsGg9KaHI-T8FK0D9BU5BQEZWAcZQRFQCxbFTBZwAaKhIH7rOGFmfZSHrpu+LAKUIHdlex7IqC54ZtS14tvgsSKmcPZRHoAX9nCL5jqIUWOAkQA" target="_blank" rel="noopener noreferrer ugc">TS Playground</a>中测试这些。</p><p class="line-space"> <br/> </p><pre> <code class="language-typescript">type JSONPrimitive = string | number | boolean | null | undefined; type JSONValue = JSONPrimitive | JSONValue[] | { [key: string]: JSONValue; }; type NotAssignableToJson = | bigint | symbol | Function; type JSONCompatible<T> = unknown extends T ? never : { [P in keyof T]: T[P] extends JSONValue ? T[P] : T[P] extends NotAssignableToJson ? never : JSONCompatible<T[P]>; }; function toJsonValue<T>(value: JSONCompatible<T>): JSONValue { return value; } function safeJsonStringify<T>(data: JSONCompatible<T>) { return JSON.stringify(data); } function safeJsonParse(text: string): unknown { return JSON.parse(text); }</code></pre><p class="line-space"> <br/> </p><p>这些可用于任何需要 JSON 序列化的情况。</p><p class="line-space"> <br/> </p><p>我已经在我的项目中使用这种策略好几年了,它通过在应用程序开发过程中及时检测潜在错误来证明其有效性。</p><p class="line-space"> <br/> </p><p>我希望这篇文章能为您提供一些新的见解。感谢您的阅读!</p><h2>有用的链接</h2><ul><li><a href="https://hackernoon.com/making-typescript-truly-strongly-typed?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">让 TypeScript 真正成为“强类型”</a></li><li> <a href="https://hackernoon.com/unleashing-the-power-of-typescript-improving-standard-library-types?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">改进 TypeScript 的标准库类型</a></li><li><a href="https://docs.superstructjs.org/?ref=hackernoon.com" target="_blank" rel="noopener noreferrer ugc">超级建筑图书馆</a></li><li><a href="https://www.typescriptlang.org/play?target=99&useUnknownInCatchVariables=true&ts=5.3.3&ref=hackernoon.com#code/C4TwDgpgBAUgygeQHIAUBOBLAth4GBu0AvFAM7CYB2A5lAD5SUCuWARhGvVKwPY8A2EAIaUuzfvy5NKAEwgAzDJQgyA3ACh1oSLERIAakP5Niu5Omy4C0BvGSHjEANoBdLgG91Ub1CcBrCBAALjIKJWoXELsDIxMNAF8NLXBoJB5gAEFSUgxqSiFWQQAVHhhSHlESLx8GVlylYChq7wZSEDYBJp8uADFpAGM8CqTtaGiAYR4sMCE8QogAHiKAPigSaT9KHgB3UQgAD2AIWVIoIqgAfkYIQk4Qz26nFCglKACQHnkzyK7unyKnm4DkcTmYYo5LmdAVAQs0-gCUEDDscZKc0plsrl8vMSmUKpDlLcYb8-mDJtNZhh5ktAcsEiMUmcIOQEKwAFYQQZrMlTGZzQQLdxQeR8EIAclYQjQYtUUBkswgIQAIgqoPE6eoAPSanwAPQumlGTPIFhweEI3ImvMp1PIVGoGu1eoNyR0RWZwAAqpRNjtKjyKfzFhstrtHTrvPrDYz3eRvb7dugeGBLXpyXyqQKhUIQiG-Wrw87NE75AMhqJSEJ5BA8ZQ4GEaBh5CAABTy4A5sEOEwASignid3TQEGATDQomiADo7eEm6320IexonfFNKXKIMMPjK9Xa-X7XOllBgSjTlbA5nFitlm3Zp2in2Hj5h6Px2Dpw3qHPbx2l+pV+oO41uUdaft+T7eCKPDipK0oADT-n+Wo6kBe5gc2LYDhGPhMGA7YqBkwAhMo2xQCqRwtj2yFqkhDQcPIQj9NAKA8OQ5JYMcjQQVAQhMMAAAWPBoAAkjIIQzjQGgAJBHIc4mfho3S4fhMiEcRLDsGg9KaHI-T8FK0D9BU5BQEZWAcZQRFQCxbFTBZwAaKhIH7rOGFmfZSHrpu+LAKUIHdlex7IqC54ZtS14tvgsSKmcPZRHoAX9nCL5jqIUWOAkQA" target="_blank" rel="noopener noreferrer ugc">TS游乐场</a></li></ul><p class="line-space"> <br/> </p></div><div style="" class="sc-394e77f1-8 cZpvsr"><button><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 22 22" width="22" style="width:18px;fill:white"><path style="width:18px;fill:white" d="M16 9h1v2h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1H9v1H8v1H7v1H6v1H0v-6h1v-1h1v-1h1v-1h1v-1h1v-1h1v-1h1V9h1V8h1V7h1V6h1V5h2v1h1v1h1v1h1v1zM22 4v2h-1v1h-1v1h-1v1h-1V8h-1V7h-1V6h-1V5h-1V4h-1V3h1V2h1V1h1V0h2v1h1v1h1v1h1v1h1z"/></svg></button><button><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 20 22" width="22" style="width:18px;fill:white"><path style="width:18px;fill:white" d="M20 3v2h-1v2h-1v1h-5V7h-2v1h-1v1H9v4h1v1h1v1h2v-1h5v1h1v2h1v2h-1v2h-1v1h-5v-1h-1v-2h-1v-2h-1v-1H9v-1H8v-1H7v1H2v-1H1v-2H0v-2h1V8h1V7h5v1h1V7h1V6h1V5h1V3h1V1h1V0h5v1h1v2h1z"/></svg></button><button><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 20 22" width="22" style="width:18px;fill:white"><path style="width:18px;fill:white" d="M14 19v2h-1v1H1v-1H0V5h1V4h3v15h10z"/><path style="width:18px;fill:white" d="M20 6v11h-1v1H6v-1H5V1h1V0h8v6h6z"/><path style="width:18px;fill:white" d="M20 4v1h-5V0h1v1h1v1h1v1h1v1h1z"/></svg></button><a style="margin-left:15px;color:white" href="#commentSection"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 22 19" width="22" style="width:18px;fill:white"><path style="width:18px;fill:white" d="M21 6V4h-1V3h-1V2h-2V1h-3V0H8v1H5v1H3v1H2v1H1v2H0v6h1v2h1v2H1v1H0v2h5v-1h1v-1h2v1h6v-1h3v-1h2v-1h1v-1h1v-2h1V6h-1ZM6 13h1v-1h1v-2H6V5h4v8H9v1H6v-1Zm6 0h1v-1h1v-2h-2V5h4v8h-1v1h-3v-1Z"/></svg></a><button style="margin-right:10px"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 20 20" width="22" style="width:18px;fill:white"><path style="width:18px;fill:white" d="M20 2v12h-1v1h-2v1h-6v-1H4v1H3v4H1V3H0V1h1V0h2v1h1v2H3v1h1V3h7v1h6V3h2V2h1z"/></svg></button><div class="sc-394e77f1-9 xselx"/></div></div></div><span style="width:1px;height:1px"/></div><div class="sc-1672ab2b-0 hLGDhs"><div class="adbytag"><div class="sc-a0a54eeb-0 QhtQk"><a href="https://communityfund.stellar.org/startup-camp?utm_source=hackernoon&utm_medium=display&utm_campaign=scfbootcamp&utm_content=keyword" target="_blank"><span style="box-sizing:border-box;display:block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;top:0;left:0;bottom:0;right:0"><img alt="Stellar" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="fill" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Stellar" sizes="100vw" srcset="https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=640 640w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=750 750w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=828 828w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=1080 1080w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=1200 1200w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=1920 1920w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=2048 2048w, https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=3840 3840w" src="https://hackernoon.imgix.net/images/img-y823byk.png?auto=format&fit=max&w=3840" decoding="async" data-nimg="fill" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span> </a></div></div><div style="display:flex;align-items:flex-end;justify-content:center"><div>L O A D I N G<br/>. . . comments & <span style="font-style:italic"> more!</span><br/></div></div><br/><section><div class="sc-be669285-0 dskenW authorBio-section"><h3>About Author</h3><div class="row"><div class="avatar "><a href="/u/nodge"><span style="box-sizing:border-box;display:block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;top:0;left:0;bottom:0;right:0"><img alt="Maksim Zemskov HackerNoon profile picture" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="fill" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;object-fit:cover"/><noscript><img alt="Maksim Zemskov HackerNoon profile picture" sizes="100vw" srcset="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 640w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 750w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 828w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 1080w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 1200w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 1920w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 2048w, https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max 3840w" src="https://hackernoon.imgix.net/images/bJKRfuzGGgcDbBCYzVZSUx2jX9J3-jz94qmn.jpeg?w=200&auto=format&fit=max" decoding="async" data-nimg="fill" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;object-fit:cover" loading="lazy"/></noscript></span></a></div><div class="author-info"><div class="author-info-top"><span class="author-name-handle"><strong>Maksim Zemskov</strong><span class="handle"><a href="/u/nodge">@<!-- -->nodge</a></span></span></div><span class="bio">Senior Software Engineer | Web | Frontend | React | TypeScript | Fullstack | Node.js</span><div class="author-cta-wrapper"><a class="bio-cta" href="/u/nodge"><i style="font-size:1.8rem"/>Read my stories</a></div></div></div></div></section><div id="commentSection"/><section class="topics-section"><h4>標籤</h4><div class="tags"><a class="sc-29806bfb-0 grqJQm parent-category" href="/c/programming"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="purcat-img" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="purcat-img" srcset="https://cdn.hackernoon.com/icons/SVG/Programming.svg?auto=format&fit=max&w=32 1x, https://cdn.hackernoon.com/icons/SVG/Programming.svg?auto=format&fit=max&w=48 2x" src="https://cdn.hackernoon.com/icons/SVG/Programming.svg?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="text-transform:uppercase;color:white;margin-left:1rem">programming</span></a><a href="/tagged/typescript" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->typescript</a><a href="/tagged/web-development" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->web-development</a><a href="/tagged/type-safety" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->type-safety</a><a href="/tagged/nodejs" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->nodejs</a><a href="/tagged/json-serialization" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->json-serialization</a><a href="/tagged/json-serialization-typescript" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->json-serialization-typescript</a><a href="/tagged/type-safe-json-serialization" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->type-safe-json-serialization</a><a href="/tagged/hackernoon-top-story" class="sc-47f2f1-0 jGbHjJ"> #<!-- -->hackernoon-top-story</a></div></section><section class="lang-section"><h4>Languages</h4><div class="tags"><a href="/zh/top" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-top-story" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-top-story" srcset="https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/usa_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">English</span></a><a href="/zh/de" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-de" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-de" srcset="https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/german-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Deutsch</span></a><a href="/zh/ja" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-ja" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-ja" srcset="https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/japan-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">日本語</span></a><a href="/zh/es" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-es" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-es" srcset="https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/spain_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Español</span></a><a href="/zh/ko" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-ko" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-ko" srcset="https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/korean-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">한국인</span></a><a href="/zh/zh" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-zh" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-zh" srcset="https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/china_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">中国人</span></a><a href="/zh/ru" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-ru" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-ru" srcset="https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/russian-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Русский</span></a><a href="/zh/tr" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-tr" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-tr" srcset="https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/turkish-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Türkçe</span></a><a href="/zh/fr" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-fr" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-fr" srcset="https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/fr_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Français</span></a><a href="/zh/hi" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-hi" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-hi" srcset="https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/hindi_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">हिंदी</span></a><a href="/zh/vi" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-vi" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-vi" srcset="https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/vi_flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Tiếng Việt</span></a><a href="/zh/pt" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-pt" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-pt" srcset="https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/portugal_flag.webp?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">Português</span></a><a href="/zh/bn" class="sc-47f2f1-0 jGbHjJ"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2720%27%20height=%2720%27/%3e"/></span><img alt="hackernoon-bn" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="hackernoon-bn" srcset="https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/bengali-flag.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="border-radius:10px;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span><span style="margin-left:10px">বাংলা</span></a></div></section><div class="sc-f99aa0e2-0 hxmNHD"><h4>这篇文章刊登在<!-- -->...</h4><div class="web-tags"><a href="https://terminal.hackernoon.com/mastering-type-safe-json-serialization-in-typescript?ref=hackernoon" target="_blank" rel="nofollow" class="sc-f99aa0e2-2 ikTyaO"><div class="sc-f99aa0e2-1 pRtcF"><span style="display:flex;cursor:pointer" data-tip="true" data-for="terminal-view"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2722%27%20height=%2722%27/%3e"/></span><img alt="Read on Terminal Reader" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Read on Terminal Reader" srcset="https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/computer.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></span> Terminal</div></a><a href="/lite/mastering-type-safe-json-serialization-in-typescript?ref=hackernoon" target="_blank" rel="nofollow" class="sc-f99aa0e2-2 ikTyaO"><div class="sc-f99aa0e2-1 pRtcF"><span style="display:flex;cursor:pointer"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2722%27%20height=%2722%27/%3e"/></span><img alt="Read this story w/o Javascript" data-tip="true" data-for="lite-tooltip" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Read this story w/o Javascript" data-tip="true" data-for="lite-tooltip" srcset="https://hackernoon.imgix.net/images/Lite%20Icon%20%4025px.png?auto=format&fit=max&w=32 1x, https://hackernoon.imgix.net/images/Lite%20Icon%20%4025px.png?auto=format&fit=max&w=48 2x" src="https://hackernoon.imgix.net/images/Lite%20Icon%20%4025px.png?auto=format&fit=max&w=48" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></span> Lite</div></a></div></div><section class="related-section"><h4>相關故事</h4><div class="articles-wrapper"><div class="sc-c12e324b-0 kWZzql"><div class="img"><a href="../zh/参议院批准了反证券决议和其他加密监管更新" style="display:contents" target="_blank" rel="noopener noreferrer"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27260%27%20height=%27150%27/%3e"/></span><img alt="Article Thumbnail" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="img" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Article Thumbnail" srcset="https://hackernoon.imgix.net/images/sBGdF0DbxXNwhS0pFRPmgiVVOt32-5i932z8.jpeg?auto=format&fit=max&w=260 1x, https://hackernoon.imgix.net/images/sBGdF0DbxXNwhS0pFRPmgiVVOt32-5i932z8.jpeg?auto=format&fit=max&w=260 2x" src="https://hackernoon.imgix.net/images/sBGdF0DbxXNwhS0pFRPmgiVVOt32-5i932z8.jpeg?auto=format&fit=max&w=260" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="img" loading="lazy"/></noscript></span></a></div><div class="text"><strong><a href="../zh/参议院批准了反证券决议和其他加密监管更新" style="text-decoration:none;text-align:left" target="_blank" rel="noopener noreferrer">全球加密监管趋紧,美国立法者联合起来反对 SEC</a></strong><div class="card-title"><div class="card-info"><span class="author"><span style="color:gray">by</span> <strong><a class="author-link" href="https://hackernoon.com/u/ilinskii">ilinskii<!-- --> </a></strong></span><div/><div class="divider-bullet"/><div class="date">Jan 01, 1970</div></div><a class="related" href="/tagged/crypto-regulation"><span class="centered"> <!-- -->#<!-- -->crypto-regulation</span></a></div></div></div><div class="sc-c12e324b-0 kWZzql"><div class="img"><a href="../zh/单页优势——软件工程项目的模板" style="display:contents" target="_blank" rel="noopener noreferrer"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27260%27%20height=%27150%27/%3e"/></span><img alt="Article Thumbnail" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="img" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Article Thumbnail" srcset="https://hackernoon.imgix.net/images/Makq4Frn8Kd7JEen0S0HMEY1jiy1-tu82xuq.jpeg?auto=format&fit=max&w=260 1x, https://hackernoon.imgix.net/images/Makq4Frn8Kd7JEen0S0HMEY1jiy1-tu82xuq.jpeg?auto=format&fit=max&w=260 2x" src="https://hackernoon.imgix.net/images/Makq4Frn8Kd7JEen0S0HMEY1jiy1-tu82xuq.jpeg?auto=format&fit=max&w=260" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="img" loading="lazy"/></noscript></span></a></div><div class="text"><strong><a href="../zh/单页优势——软件工程项目的模板" style="text-decoration:none;text-align:left" target="_blank" rel="noopener noreferrer">单页优势:软件工程项目的模板</a></strong><div class="card-title"><div class="card-info"><span class="author"><span style="color:gray">by</span> <strong><a class="author-link" href="https://hackernoon.com/u/vlshahane">vlshahane<!-- --> </a></strong></span><div/><div class="divider-bullet"/><div class="date">Jan 01, 1970</div></div><a class="related" href="/tagged/team-management"><span class="centered"> <!-- -->#<!-- -->team-management</span></a></div></div></div><div class="sc-c12e324b-0 kWZzql"><div class="img"><a href="../zh/看不见的层面为什么用户访谈是不可替代的资产" style="display:contents" target="_blank" rel="noopener noreferrer"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27260%27%20height=%27150%27/%3e"/></span><img alt="Article Thumbnail" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" class="img" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="Article Thumbnail" srcset="https://hackernoon.imgix.net/images/ekG9jTnTqmaV0offB3XQIFqYrY93-uc83c2m.jpeg?auto=format&fit=max&w=260 1x, https://hackernoon.imgix.net/images/ekG9jTnTqmaV0offB3XQIFqYrY93-uc83c2m.jpeg?auto=format&fit=max&w=260 2x" src="https://hackernoon.imgix.net/images/ekG9jTnTqmaV0offB3XQIFqYrY93-uc83c2m.jpeg?auto=format&fit=max&w=260" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="img" loading="lazy"/></noscript></span></a></div><div class="text"><strong><a href="../zh/看不见的层面为什么用户访谈是不可替代的资产" style="text-decoration:none;text-align:left" target="_blank" rel="noopener noreferrer">看不见的层面:为什么用户访谈是不可替代的资产</a></strong><div class="card-title"><div class="card-info"><span class="author"><span style="color:gray">by</span> <strong><a class="author-link" href="https://hackernoon.com/u/vvmrk">vvmrk<!-- --> </a></strong></span><div/><div class="divider-bullet"/><div class="date">Jan 01, 1970</div></div><a class="related" href="/tagged/startup"><span class="centered"> <!-- -->#<!-- -->startup</span></a></div></div></div></div></section><div class="sc-92a1b621-1 fbBMII"><a class="fs-hn-cta" href="https://hackernoon.com/login"><div class="cta-top"><small>Join HackerNoon</small><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2770%27%20height=%2770%27/%3e"/></span><img alt="loading" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/><noscript><img alt="loading" srcset="https://hackernoon.com/watch-gif.gif?auto=format&fit=max&w=96 1x, https://hackernoon.com/watch-gif.gif?auto=format&fit=max&w=256 2x" src="https://hackernoon.com/watch-gif.gif?auto=format&fit=max&w=256" decoding="async" data-nimg="intrinsic" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/></noscript></span></div><strong>Latest technology trends. Customized Experience. Curated Stories. Publish Your Ideas </strong></a></div></div></main></div></div></body>
推荐文章
坚韧的马克杯
·
“618”深度观察|拼多多、阿里、京东及抖音“厮杀”进行时_新浪科技_新浪网
2 天前
不羁的仙人掌
·
Implementing React Speech Recognition in Your Apps
1 周前
调皮的遥控器
·
平安传无删减完整版(西风紧)-平安传无删减完整版小说免费阅读-草原红小说
3 月前
率性的羽毛球
·
沉浸视觉体验“镜”收眼底 佳能推出3D VR影像拍摄的EOS VR系统
6 月前
从容的脆皮肠
·
比亚迪唐方向盘价格报价行情 - 京东
1 年前