> From: Stephen Hemminger [mailto:step...@networkplumber.org] > Sent: Thursday, 23 June 2022 20.40 > > On Thu, 23 Jun 2022 20:34:07 +0200 > Morten Brørup <m...@smartsharesystems.com> wrote: > > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com] > > > Sent: Thursday, 23 June 2022 18.43 > > > > > > For string values returned from telemetry, escape any values that > > > cannot > > > normally appear in a json string. According to the json spec[1], > the > > > characters than need to be handled are control chars (char value < > > > 0x20) > > > and '"' and '\' characters. > > > > Correct. Other chars are optional to escape. > > For json_writer (which I wrote for iproute2 and could have been used > here). > The switch handles: \t \n \r \f \b \\ " ' as special cases.
RFC 8259 chapter 7 says: All Unicode characters may be placed within the quotation marks, except for the characters that MUST be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F). I have no preference for either, as long as '/' and other non-control characters are not (unnecessarily) escaped. Using tested and maintained code like json_writer could be beneficial. If you hold the copyright, there should be no license issues.