TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Tools to declare typed structs across languages

2 pointsby dpkrjbover 2 years ago
Hi HN, Can someone help point me in the right direction? I&#x27;m looking for a tool to simplify the code generation of typed structs across platforms. This (boring) tool would allow me to:<p>1. Declare the schema of many data types<p>2. Use the schema to generate structs from those data types in multiple languages (Golang, Typescript, Dart)<p>3. Easily serialize and deserialize those types to and from JSON<p>My Google-fu seems to be pretty awful because I cannot find a single tool that allows me to declare a type schema without it also being an alternative to JSON.<p>Any boring solutions out there?

3 comments

orbzover 2 years ago
<a href="https:&#x2F;&#x2F;developers.google.com&#x2F;protocol-buffers" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;protocol-buffers</a> Is boring but works.
nerpderp82over 2 years ago
Is json a hard requirement?<p><a href="https:&#x2F;&#x2F;capnproto.org&#x2F;otherlang.html" rel="nofollow">https:&#x2F;&#x2F;capnproto.org&#x2F;otherlang.html</a> allows for a serialization free solution.
tantonyover 2 years ago
XML is old-school, but it works. Any program that processes the XML schema can validate them using XSD files. Repetition can be avoided using extensions like xpath and xinclude.