Friendica
  • Anmelden
elrido
elrido

elrido

elrido@social.dssr.ch

elrido

elrido@social.dssr.ch
C/C++/Rust Entwickler mit Schwerpunkt Sicherheit (C/C++/Rust developer, focused on security)
Folge
Atom-Feed
Netzwerkbeiträge

Zurich, Switzerland

-----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2qxPfkKa7qzrJvPfebd8 c93clvwF1fGO0bLs1ma0FXLK6FjeWAF4yDTEeir/P3LBer1Sr/nJkoCYAbYuxD4G sEJSvojRN2Xz+NqNtxeMCg3ZjjWBVA2jrMQ6yWUb9nn/9v3rhRP7mBGriJHaMA1Q mneCUc/yaKQnb18cxM2pqk4reCNyPezOYA3pPiiqMF77/Yn/HIGqvbsaOyex/CX6 1KmZATvUhnEAnuZl76GGaMP8LNHFGzjLUihCb5PkgWAt0e2XTdvaa7Qw2vregXc6 T/JltiSn024r/k2JsNX+HDKZ/+BpdNl2Lu8WU3hgcoh9EZ082cUIyQNKRkE9Qta3 hCSefMe97kNs/MGTqHDfRACKOUAEJyy0m/diHg9QR7btnvlFXqyxw18yK0qCiBnv URbGB18+E4/zuo/zvGFH217FrG7Jt4lAmhsIEDXfTp+8Es0QCkuScm3/pDbeLN5p mDAYsjIEtJ7YmprcjpIzK76PUZn49Msih3Ea9DswQS7VzpphtiyIVTttbx3rRWPJ rfgUow6uLNvid84q0uFHgBpElFe9HajAqb4V4V4IdrR9oW3t5rWRs5EKT7/DuWVg o+pHMU0Vx6Se2zSXoFmF3ljeNhIltgVMbIs+onlunGXCXLoLs+qZWK+PD5nEEaVu CO+6fDET/pX1Bv0a8yq3+TUCAwEAAQ== -----END PUBLIC KEY-----
2026-01-27T06:41:28+00:00
http://simon.rupf.net/
Über:
C/C++/Rust Entwickler mit Schwerpunkt Sicherheit (C/C++/Rust developer, focused on security)
Uid
b763998230b4da3d
Nickname
elrido
Full_name
elrido
Searchable
true
First_name
elrido
Family_name
Url
https://social.dssr.ch/
Photo
Photo_medium
Photo_small
2023-07-05 15:42:01 2023-07-05 15:40:08 2023-07-05 15:40:08 1657743

elrido
elrido
friendica (DFRN) - Link zum Originalbeitrag

elrido

Wednesday, July 5, 2023, 15:40 •
(Schweiz)

elrido

Wednesday, July 5, 2023, 15:40  — (Schweiz) •


At work we use more and more YAML documents (with all it's benefits and issues) so I've long started using a handy python alias to convert them into JSON to query them using jq:

alias yaml2json='python3 -c '\''import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))'\'''

Because we also started using it in the test harness to validate YAML documents, we made it available to that environment as well. Test creates some YAML report, which is piped into yaml2json, which is piped into jq --exit-status '[...tests here...]'.

Fast forward a few months, more tests got added, and eventually I notice that one of these, on a 30k line document, spends about 15 seconds just converting it. Hm.

Now, it's not like there are not already tons of C, C++, Go, Rust, etc. versions of that tool around, I'm aware of many of those, unfortunately none are p

... mehr anzeigen

At work we use more and more YAML documents (with all it's benefits and issues) so I've long started using a handy python alias to convert them into JSON to query them using jq:

alias yaml2json='python3 -c '\''import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))'\'''

Because we also started using it in the test harness to validate YAML documents, we made it available to that environment as well. Test creates some YAML report, which is piped into yaml2json, which is piped into jq --exit-status '[...tests here...]'.

Fast forward a few months, more tests got added, and eventually I notice that one of these, on a 30k line document, spends about 15 seconds just converting it. Hm.

Now, it's not like there are not already tons of C, C++, Go, Rust, etc. versions of that tool around, I'm aware of many of those, unfortunately none are prepackaged for the distro used around here. Still, it nags me. I know that in Rust we have all these convenient Serde libraries. Would be trivial to write it using these. People have done so. Hm. And we could make a little wrapper around jq, like yq (python), which makes it easier to use. And we could also support other formats, like XML or CSV, like yq (Go) - the latter also replicates jq itself, that seems a step too far and risks running into incompatibilities, jq itself does the job alright.

So, eventually I did put these puzzle pieces together and we have yet-another-format-to-JSON-converter: github.com/simonrupf/convert2j…

Unique selling points? Well I've experimented a bit with github actions and it is indeed not to difficult to automate the release and publication of statically linked RPMs (for use on different RPM-based distros) and dynamically linked binaries for Ubuntu, MacOS (universal binaries for x86_64 & aarch64) and even Windows (untested - I have no access to that OS, nor do I want to). I'll try to keep it light weight and have some automation set up to keep it updated when dependencies change.

And yes, that 30k YAML file now parses in 0.2s instead of 13s. OCD satisfied.

GitHub - Nessex/yaml2json-rs: Command line utility (+libraries) to convert YAML to JSON.

Command line utility (+libraries) to convert YAML to JSON. - GitHub - Nessex/yaml2json-rs: Command line utility (+libraries) to convert YAML to JSON.
GitHub
  •  Sprache erkennen
  •  Rohdaten
  •  Teile mit...
⇧