News for hackers. Stuff that matters.
Re:JSON for Modern C++ version 3.10.0 by modeless on Thursday August 19, 2021 @02:55AM (#28231131)
Huh, I was just in some code that uses this library a few days ago. I wish it included a base64 implementation for more efficiently encoding arrays of bytes or floats. JSON is inefficient for large arrays of numbers.
Re:JSON for Modern C++ version 3.10.0 by jcelerier on Thursday August 19, 2021 @03:00AM (#28231151)
Why wouldn't you use a base64 library ? This is prime library bloat mindset. Base64 has nothing to do in a JSON lib; there are a ton of implementations out there.
Re:JSON for Modern C++ version 3.10.0 by modeless on Thursday August 19, 2021 @10:28AM (#28234245)
A base64 implementation is very small, but not completely trivial to the point where you should implement it yourself, or paste in a one liner from Stack Overflow. It's widely used with JSON. C++ has no package manager to make it easy to import tiny libraries for purposes like this, so C++ libraries should be a little more self contained than npm packages or rust crates. It would absolutely be reasonable to include a base64 implementation in a C++ JSON library for those reasons.
Re:JSON for Modern C++ version 3.10.0 by tsbinz on Thursday August 19, 2021 @03:25AM (#28231292)
Uh, it has plenty of methods for more compact encodings? https://github.com/nlohmann/json#binary-formats-bson-cbor-me...
Re:JSON for Modern C++ version 3.10.0 by modeless on Thursday August 19, 2021 @10:23AM (#28234184)
Sure, if you want to change the format of the whole message. If you're communicating with something that accepts JSON and you can't or don't want to change that, then having a more efficient option is nice.