Prevent backslash escape from serde_json when deserializing

Hi all,

I'm storing some configuration data into a file. This file contains a regex array of strings, which can possibly contains a lot of \ chars. I'm thinking of JSON for storing this.

But the JSON format incurs escaping this \ char, which is not really convenient for a regex. Is there a way for serde_json to not escape this char, and read it as is ? Or is it completely enforced with no option to circumvent this behavior ?

An alternative solution could be to switch to YAML, which seems to not suffer from such a constraint...

Thanks for any hint.

TOML, the same format Cargo uses for its config file, has a literal string format, would that work instead?

regex    = '<\i\c*\s*>'

@Douglas Thanks for the hint, I also thinked of TOML, but I need to overhaul some stuff.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.