Settings

Theme

Ask HN: Tools to declare typed structs across languages

2 points by dpkrjb 3 years ago · 3 comments · 1 min read


Hi HN, Can someone help point me in the right direction? I'm looking for a tool to simplify the code generation of typed structs across platforms. This (boring) tool would allow me to:

1. Declare the schema of many data types

2. Use the schema to generate structs from those data types in multiple languages (Golang, Typescript, Dart)

3. Easily serialize and deserialize those types to and from JSON

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.

Any boring solutions out there?

orbz 3 years ago

https://developers.google.com/protocol-buffers Is boring but works.

nerpderp82 3 years ago

Is json a hard requirement?

https://capnproto.org/otherlang.html allows for a serialization free solution.

tantony 3 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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection