您好我正在尝试从 Java 中的字符串加载配置,如下所示:
@Test
public void testIllegalCharacter(){
String input = "prop=\\asd";
Config conf = ConfigFactory.parseString(input);
}
上面的代码产生以下错误:
com.typesafe.config.ConfigException$Parse: String: 1: Expecting a value but got wrong token: '\' (Reserved character '\' is not allowed outside quotes) (if you intended '\' (Reserved character '\' is not allowed outside quotes) to be part of a key or string value, try enclosing the key or value in double quotes, or you may be able to rename the file .properties rather than .conf)
我知道我的字符串中有非法字符。虽然我如何找到全套非法字符?
如果我(例如)将此 String 转换为一个Properties对象,然后用它解析它,我可以看到ConfigFactory.parseProperties解析"\\asd"为看不到怎么做。解析到属性不是一个可行的解决方案,因为配置也可以由对象或列表组成。"asd".
有没有人有任何建议如何解决这个问题?
或者有人可以指出所有保留字符集吗?
非常感谢