I want to import data with YAML. I have a model named Question
package models;
import java.util.*;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import play.data.validation.*;
import play.db.jpa.Model;
@Entity
public class Question extends Model{
@Required
public String question;
@Required
public String[] choices ;
@ManyToOne
public TestClass test;
@Required
public Integer trueChoice;
public Question(TestClass test, Integer trueChoice, Choices[] choices, String question){
this.test = test;
choices = new Choices[4];
this.trueChoice = trueChoice;
this.question = question;
}
}
In this model i have choises array. How can i load this array with yaml?
If you look at the YAML documentation (section 2.1) or the Wikipedia page, they describe how lists are used. a list is described by using the dash symbol (
-) for each item, on a new line. Please note the indentation.For your example, you would have something like the following: