I have YAML file like this..
Product:
 ProductA:
  Suite:
    SuiteName_A:
      Environment_1: ["A","B","C"]
      Environment_2: ["X","Y","Z"]
    SuiteName_B:
      Environment_1: ["E","F","G"]
      Environment_2: ["K","L","M"]
 ProductB:
  Suite:
    SuiteName_K:
      Environment_1: ["A1","B2","C3"]
      Environment_2: ["X1","Y1","Z1"]
Edited---- I have created few classes as I read in some read article and here what i came up with..
Environment Class
    package Configuration;
import java.util.ArrayList;
public class Environment {
    private ArrayList<String> Environment_1;
    private ArrayList<String> Environment_2;
    public ArrayList<String> getEnvironment_1() {
        return Environment_1;
    }
    public void setEnvironment_1(ArrayList<String> Environment_1) {
        this.Environment_1 = Environment_1;
    }
    public ArrayList<String> getEnvironment_2() {
        return Environment_2;
    }
    public void setEnvironment_2(ArrayList<String> Environment_2) {
        this.Environment_1 = Environment_2;
    }
}
SuitName Class
    package Configuration;
import java.util.HashMap;
public class SuiteNames {
    private HashMap<String,Environment> Suite;
    public HashMap<String, Environment> getSuite() {
        return Suite;
    }
    public void setSuite(HashMap<String, Environment> suite) {
        Suite = suite;
    }
}
Product Class
    package Configuration;
import java.util.HashMap;
public class Product {
    private HashMap<String,SuiteNames> Product;
    public HashMap<String, SuiteNames> getProduct() {
        return Product;
    }
    public void setProduct(HashMap<String, SuiteNames> product) {
        this.Product = product;
    }
}
Main Class
    package Configuration;
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class DbClass {
    public static void main(String[] args) throws FileNotFoundException {
        Yaml yaml = new Yaml();
        InputStream inputStream = new FileInputStream("path");
        System.out.println(inputStream);
        Product product = yaml.loadAs(inputStream,Product.class);
        System.out.println(product.getProduct());
    }
}
This gives following error:
     Exception in thread "main" Cannot create property=Product for JavaBean=Configuration.Product@4c98385c
 in 'reader', line 1, column 1:
    Product:
    ^
Unable to find property 'Product' on class: Configuration.Product
 in 'reader', line 2, column 3:
      Check-in:
      ^
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:270)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:149)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:309)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:216)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:205)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:164)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:148)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:525)
    at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:519)
    at Configuration.DbClass.main(DbClass.java:17)
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'Product' on class: Configuration.Product
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:159)
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:148)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:287)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:208)
    ... 9 more
I want get the list of Environent names and to store this in a list. I am aware using jackson api. But I don't know how to map this data to class. I am using servlets and inside the servlet i want to have a java method to get the list of strings.
 
     
    