-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YamlFile#load & #loadWithComments behave different on double quote value #79
Comments
Using the following produces not the expected output (replaces the input with the output mentioned in the post before) YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test", Arrays.asList("&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers"));
System.out.println(yaml.saveToString()); but the following snippets do YamlFile yaml = new YamlFile();
yaml.set("test", Arrays.asList("&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers"));
System.out.println(yaml.saveToString()); YamlFile yaml = new YamlFile();
yaml.set("test", "&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers");
System.out.println(yaml.saveToString()); YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test", "&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers");
System.out.println(yaml.saveToString()); |
somehow leaving out the YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test", Arrays.asList("%plugin_so-sum_{cat}_{sub-cat}% in %plugin_so-count_{cat}_{sub-cat}% offers"));
System.out.println(yaml.saveToString()); |
According to your examples seems to be an issue with list elements having some special characters while using the comment parser. With a simple string value does not happen 🤔
Try these other snippets independently and see if the same happens:
|
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers"), QuoteStyle.DOUBLE);
System.out.println(yaml.saveToString()); outputs
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("&8%plugi_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers"));
System.out.println(yaml.saveToString()); outputs
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("&8%plugin_so-sum%&8 in &8%plugin_so-count%&8 offers"));
System.out.println(yaml.saveToString()); outputs
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("abcd&8%plugin_so-sum_{cat}_{sub-cat}%&8 in &8%plugin_so-count_{cat}_{sub-cat}%&8 offers"));
System.out.println(yaml.saveToString()); outputs
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("&8%plugin_so-sum_%cat%_%sub-cat%%&8 in &8%plugin_so-count_%cat%_%sub-cat%%&8 offers"), QuoteStyle.DOUBLE);
System.out.println(yaml.saveToString()); outputs
YamlFile yaml = new YamlFile();
yaml.options().useComments(true);
yaml.set("test",Arrays.asList("&8%plugin_so-sum_cat%_%sub-cat%%&8 in &8%plugin_so-count_%cat%_%sub-cat%%&8 offers"));
System.out.println(yaml.saveToString()); outputs
|
using the following works in 1.7.3 but not in 1.8.1 1.8.2 1.8.3 YamlFile yaml = new YamlFile();
yaml.set("test",Arrays.asList("&8%plugin_so-sum_%cat%_%sub-cat%%&8 in &8%plugin_so-count_%cat%_%sub-cat%%&8 offers"));
yaml = YamlFile.loadConfiguration(new StringReader(yaml.saveToString()), true);
System.out.println(yaml.saveToString()); |
Using SnakeYamlImplementation works. DumperOptions dop = new DumperOptions();
dop.setWidth(10);
YamlFile yaml = new YamlFile();
yaml.set("test",Arrays.asList("&8%plugin_so-sum_%cat%_%sub-cat%%&8 in &8%plugin_so-count_%cat%_%sub-cat%%&8 offers"), QuoteStyle.DOUBLE);
String savedToString = yaml.saveToString();
System.out.println(savedToString);
yaml = new YamlFile(new SimpleYamlImplementation(new LoaderOptions(), dop));
yaml.options().useComments(true);
yaml.loadFromString(savedToString);
System.out.println(yaml.saveToString()); outputs
where as DumperOptions dop = new DumperOptions();
dop.setWidth(100);
YamlFile yaml = new YamlFile();
yaml.set("test",Arrays.asList("&8%plugin_so-sum_%cat%_%sub-cat%%&8 in &8%plugin_so-count_%cat%_%sub-cat%%&8 offers"), QuoteStyle.DOUBLE);
String savedToString = yaml.saveToString();
System.out.println(savedToString);
yaml = new YamlFile(new SimpleYamlImplementation(new LoaderOptions(), dop));
yaml.options().useComments(true);
yaml.loadFromString(savedToString);
System.out.println(yaml.saveToString()); outputs
|
Version: 1.8.4
i have a yaml file:
when i load it with YamlFile#load everything is fine.
when i load it with YamlFile#loadWithComments the file now looks like this:
this is not the behaviour i expected because there are no "#" denoting a comment
The text was updated successfully, but these errors were encountered: