TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: quicktype converts JSON, TypeScript, GraphQL to types in 18 languages

8 点作者 dvdsgl将近 5 年前

1 comment

dvdsgl将近 5 年前
Hello, HN!<p>quicktype generates types and serializers from JSON, JSON Schema, TypeScript, and GraphQL queries, to help you use JSON type-safely in many languages: C#, Go, Rust, Crystal, C++, Objective-C, Java, TypeScript, JavaScript, JavaScript PropTypes, Flow, Swift, Kotlin, Elm, JSON Schema, Ruby, Dart, Python, Pike, and our latest language, Haskell.<p>quicktype has some remarkable features that differentiate it from other JSON converters:<p><i>Type inference</i>: quicktype infers optionals, dates, UUIDs, enums, integers, and unions. It also infers maps (versus objects) using a Markov chain.<p><i>Careful naming</i>: quicktype’s naming system creates nice, legal, unique names for types and properties, handling reserved words and tricky corner cases (e.g. `{ “”: “this is legal”, “null”: “so is this”, &quot;1;DROP TABLE users”: “and this&quot; }`).<p><i>Unions for heterogeneous data</i>: JSON data is often heterogenous. quicktype infers this, and creates union types in languages that support them, or synthetic union types in languages that don’t (e.g. try quicktyping `[0, “zero”]` as Swift and Go).<p><i>Type unification</i>. This works across multiple samples, so you can quicktype a directory of API data, for example, and unify types across all responses (e.g. you’ll get just one `Customer` type, even if customer data occurs in many samples). You can also provide multiple samples for the same type for better coverage.<p><i>Marshalling code</i>: In addition to types, quicktype generates functions for marshalling your types to and from JSON.<p><i>Supports dynamic languages</i>: quicktype can add dynamic typechecks for JavaScript, TypeScript, Flow, Python, and Ruby.<p><i>Convenient CLI</i>: Run `quicktype <a href="https:&#x2F;&#x2F;blockchain.info&#x2F;latestblock" rel="nofollow">https:&#x2F;&#x2F;blockchain.info&#x2F;latestblock</a> -o LatestBlock.ts` to quicktype a Bitcoin API in TypeScript.<p><i>Private hosted app</i>: <a href="https:&#x2F;&#x2F;app.quicktype.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;app.quicktype.io&#x2F;</a> runs quicktype on the client, so servers never see your data (most JSON converters send your JSON to their server)<p><i>Typed input</i>: Feed quicktype TypeScript or JSON Schema instead of JSON for better control over generated types.<p><i>Code quality</i>: quicktype emits clean code
评论 #23378173 未加载