使用Java读取yaml文件-无法读取列表列表

时间:2019-07-13 12:25:53

标签: java arraylist snakeyaml

我正在使用Java读取yaml文件,并且在我的yaml文件中有ArrayList of Arraylists

但是在读取文件时并没有获取文件的内容。

我得到的结果如下。

Persons 
    [persons=
        [
            [name, phone, address], 
            [name, phone, address], 
            [name, phone, address, favorite],
            [name, phone, address]
        ]
    ]

请找到我的yaml文件

persons:
 - name: Joe
   phone: 111-111-1111
   address: Park Dr, Charlie Hill

 - name: Trish
   phone: 111-111-11111
   address: Small Vine, River Town

 - name: Karthik
   phone: 111-222-2222
   address: Park Avenue
   favorite:
    - game1: Tennis
    - game2: FootBall
 - name: Anushka
   phone: 111-333-4444
   address: London

请找到我的模型课程文件

Favorite.java

public class Favorite {

    private String game1;
    private String game2;

}

Person.java

public class Person {

      private String name;
      private String phone;
      private String address;

      private List<Favorite> favorite;


}

Persons.java

public class Persons {

     private ArrayList<ArrayList<Favorite>> persons;


}

0 个答案:

没有答案