Skip to content

Support for arrays of tables #17

@quux00

Description

@quux00

The TOML GitHub page has an example of arrays of tables (which may or may not be nested) that jtoml seems not to support. The example is:

foo = "bar"

[[fruit]]
  name = "apple"

  [[fruit.variety]]
    name = "red delicious"
  [[fruit.variety]]
    name = "granny smith"

[[fruit]]
  name = "banana"

  [[fruit.variety]]
    name = "plantain"

baz = "quux"

Note: I added the foo and baz sections to check that something was parsing.

When I try this example in jtoml, it returns nothing for the key "fruit".

File f = new File("fruit.toml");
Toml t = Toml.parse(f);
System.out.println(t.getString("foo")); // prints bar
System.out.println(t.getString("baz")); // prints null
Object object = t.get("fruit");
System.out.println(object);             // prints null

Request: jtoml should support this.

Note: I used version 1.1.0 for this test.

Also, notice that the getString("baz") returns null. If I put the baz="quux" at the top of the file, it returns "quux", so it looks like the jtoml parser just stops when it hits a part of the file it considers an error and stops parsing. This seems like a defect in the parser. In my view, it should throw an exception if the TOML file is invalid. Perhaps I should file another issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions