I am reading a yaml file and I am writing it simply to a path (e.g. I am reading a test.yml file and writing it to tester.yml). I can now read and write the file but the actual problem is that I am getting "!java.util.LinkedHashMap" in my out put file. I am using YAML BEANS to read and write to the file.
MY Output: !java.util.LinkedHashMap Error: !java.util.LinkedHashMap type: object properties: !java.util.LinkedHashMap errorMessage: !java.util.LinkedHashMap type: string description: Message describing the error (Do not give too much information, to avoid security reach) errorLevel: !java.util.LinkedHashMap type: string description: Criticity level of error default: info enum: - info - warning - error - critical errorType: !java.util.LinkedHashMap type: string description: Type of error enum: - functional - technical documentationUrl: !java.util.LinkedHashMap type: string description: Url of the documenation associated to the error tips: !java.util.LinkedHashMap type: string description: Tips/help for adressing the error required: - errorMessage - errorCode
MY code
Reader targetReader = new InputStreamReader(uploadedFile);
YamlReader yamlReader=new YamlReader(targetReader);
YamlWriter yamlWriter= new YamlWriter(new FileWriter("filename"));
Object object = yamlReader.read();
System.out.println(object);
yamlWriter.write(object);
yamlWriter.close();
MY Input Error: type: object properties: errorMessage: type: string description: >- Message describing the error (Do not give too much information, to avoid security reach) errorLevel: type: string description: Criticity level of error default: info enum: - info - warning - error - critical errorType: type: string description: Type of error enum: - functional - technical documentationUrl: type: string description: Url of the documenation associated to the error tips: type: string description: Tips/help for adressing the error required: - errorMessage - errorCode
Any help and suggestions are welcome thanks in advance..... Solution for this one is
yamlWriter.getConfig().writeConfig.setWriteClassname(YamlConfig.WriteClassName.NEVER);
yamlWriter.getConfig().writeConfig.setWriteRootTags(false);