YAML get anoymus list entrys

Discussion in 'Plugin Development' started by Mr. X, Jan 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Mr. X

    Hey guys!
    I have a config whose contans a list with items whicht have no names now i try to load it but i found no method to do is.My config:
    Code:
    groups:
    - data:
        name: '1234'
    - data:
        name: '45678'
    i want to get the data sections anyone who know the answer?
     
  2. Offline

    fireblast709

    if you just use a config like:
    Code:
    groups:
      data:
        name: '1234'
      data2:
        name: '45678'
    Then you can use
    Code:java
    1. Set<String> keys = someConfig.getConfigurationSection("groups").getKeys(false);
    2. for(String key : keys)
    3. {
    4. someConfig.get("groups."+key+".name");
    5. }
     
  3. try getList() as the - is an token for an list
     
  4. Offline

    fireblast709

    what I am wondering about is what it returns? I know it returns a Map, but of what type? Map<String, Object>?
     
  5. Offline

    Clavus

    This is what I used:
    Code:java
    1. List<LinkedHashMap<String, Object>> configList = (List<LinkedHashMap<String, Object>>) config.getList("groups");

    I wonder if you could somehow turn the HashMap back into a ConfigurationSection though.
     
  6. Offline

    fireblast709

    o a List<HashMap<String, Object>>... seems plausible (and is probably correct)
     
Thread Status:
Not open for further replies.

Share This Page