On Tue, May 02, 2023 at 02:41:52PM +0200, Claudio Jeker wrote: > On Tue, May 02, 2023 at 02:29:20PM +0200, Theo Buehler wrote: > > On Tue, May 02, 2023 at 02:13:27PM +0200, Claudio Jeker wrote: > > > Add a json_do_string() a function to print a JSON string. > > > This function does the needed encoding of control chars and escape chars. > > > I skipped the optional encoding of the forward slash (/) since this is > > > only needed if the json output is embedded in HTML/SGML/XML. > > > People putting JSON into such documents need to pass this through an extra > > > step. > > > > > > This implements json_do_printf() now as a wrapper around json_do_string(). > > > All users of json_do_printf(name, "%s", value) can be converted to > > > json_do_string(). I will do this is a subsequent step. > > > > I'm ok with this. Some comments below. > > How about this version? By moving the !eb check into the while loop the > if checks fall away and so it is just one fprintf() per case. I think > trying to optimize this further is not that benefitial. I wonder if the > compiler wont do that better anyway.
Agreed. ok