4

次のような YAML ファイルがあります。

Main:
  topofhouse:
    x: 276.4375
    y: 71.0
    z: -60.5
    yaw: -290.7768
    pitch: 35.400017
  2ndfloor:
    x: 276.5
    y: 67.0
    z: -60.5
    yaw: -8.626648
    pitch: 16.199997
  home:
    x: 276.5
    y: 63.0
    z: -60.5
    yaw: -18.976715
    pitch: -32.850002

の下にすべてのノードを取得する方法はありMainますか?

4

1 に答える 1

6

に含まれるノード ID を取得するにはMain:

file.getConfigurationSection("Main").getKeys(false);

出力:

Set["topofhouse", "2ndfloor", "home"]

このConfigurationSection.getConfigurationSection(String path)メソッドは、操作対象のパスを取得するために使用されます。

このConfigurationSection.getKeys(boolean deep)メソッドは、現在のパス内のすべてのノード ID を として取得しますSet<String>deepが に設定されている場合true、子とサブ子のすべてのノードも取得されますが、それらの間の関係はすべて失われます。

于 2012-03-10T20:34:17.487 に答える