Working with arrays in YAML

Discussion in 'Bukkit Help' started by cyklo, Feb 9, 2011.

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

    cyklo

    I've never worked with Java before, so apologies if the documentation for this is really obvious.

    So I've started trying to get my feet wet with Java + Bukkit this evening, and one stumbling block has been trying to work with arrays in YAML files (like those used by Permissions). The bit that has me confused is how to get & set values from arrays, as shown in the test.foobar section in the sample YAML below.

    Code:
    test:
        foo: 1
        foobar:
            - 1000
            - 1001
            - 1002
        
    The method I am using for accessing YAML files is like so:
    Code:
    getConfiguration().getInt("test.foo", 3);
    getConfiguration().setProperty("test.bar", 16);
    getConfiguration().save();
    --- merged: Feb 9, 2011 9:03 PM ---
    Solved my own problem, apologies. Here's how if anyone else cares:

    Code:
    // Setting
    getConfiguration().setProperty("test.foobar", new Integer[] {1000, 1001, 1002});
    
    // Getting
    List<Integer> readBackIn = getConfiguration().getIntList("test.foobar", Arrays.asList(1000,1001,1002));
     
Thread Status:
Not open for further replies.

Share This Page