On 8/14/23 12:54, Niall Douglas via Boost-users wrote:
Unlikely. Remember, this is for an embedded target. We are fortunate enough to have a 32 bit core. simdjson requires a 64 bit CPU. I always preferredhttps://github.com/chadaustin/sajson over simdjson, because sajson is completely in-place, you feed it a buffer and no further allocations are done.
Thanks for the pointer. My searches hadn't turned-up this particular implementation.
And, yes, of course ... tradeoffs. I was hopeful when I read that "Boost.JSON works great on embedded devices." For the kinds of embedded work we do, this is probably not the case. We don't tend to parse and reedit JSON. We tend to use JSON as a message serialization mechanism. "Embedded" means a lot of things. I'd personally call it "whatever Arduino can do", but even that is pretty full featured nowadays, there is malloc and free on Arduino, std::string works as you'd expect, as does std::vector. Plenty of smaller embedded can't do any of that.
I have no idea if Boost.JSON can work on Arduino, but I suspect unless it's tested by CI to at least build under Arduino, it probably does not.
Last time I checked Arduino does support a particularly ancient port of Boost, somebody hand forked and patched it. So it is theoretically doable for somebody who likes masochism.
Of course, just because it compiles doesn't mean you'll fit your Boost using library into a few hundred Kb of Flash or RAM, so I suggest better to stick with libraries specifically designed to work well within dozens of Kb.
The micros have started to include more code storage s.t. it is possible to run a library that takes 100KiB. We only get a couple of those before we have to rethink our strategy. Thankfully, I'm not constrained to the PIC, a particularly hostile development environment--IMHO. Mostly, the tricky part is in mixing cooperative threading with, well, almost anything not cut from whole cloth. E.g. Parse JSON. Submit to driver for asynchronous processing. Return to scheduler (releasing the stack). Resume when async process complete. We /can/ malloc. Or, we can find a library that doesn't require it. sajson seems to fit the bill. Cheers -- /Marc Oscar Singer/ *Woollysoft* +1.206.328.1718