I am working on a simple project where I need to write person data into a yaml file . I am using yamlbeans to serialize and de-serialize the data. I specifically want all the java bean properties to be String. Here's how my bean properties looks like:
String employeeID;
String firstName;
String lastName;
String email;
List<String> activities;
List<String> skills;
String comments;
List<String> contracts;
String seniority
String endDate;
String hourlyWage;
String startDate;
String teamName;
I was able to successfully write a yaml file with the following example values:
!PersonBean
comments: ' '
contracts: []
email: first.last@email.com
employeeID: 12344
endDate: 12/30/1899
firstName: John
hourlyWage: 45
lastName: Doe
seniority: 0
siteName: Toronto
skills:
- Technical
- Test
startDate: 1/14/2019
However when I am trying to read the file using YamlReader, I get an error message showing Expected data for a com.example field but found: scalar. I can see the created yaml file writes the hourlywage / employee id/ Seniorty as ints and not strings
I have read multiple posts related to this problem and couldn't find a conclusive solution. Here's my question:
I want my bean properties to stay string (this is a must), So I would like to know: - Is there a way to write all the values as strings (I have tried surrounding them with quotes, and I get the same error message while reading the file) - (OR) Is there a way to read those ints as strings while using the YamlReader?
Thanks in advance for any pointers/solutions! Cheers!