如何在 Chapel 中加载可变长度 JSON 数组?

How to load variable length JSON arrays in Chapel?

我正在尝试加载 Yummly Data,其中包含 JSON 格式的训练数据。这是单个记录的示例:

  {
    "id": 10259,
    "cuisine": "greek",
    "ingredients": [
      "romaine lettuce",
      "black olives",
      "grape tomatoes",
      "garlic",
      "pepper",
      "purple onion",
      "seasoning",
      "garbanzo beans",
      "feta cheese crumbles"
    ]
  }

这是我尝试加载此数据的尝试

use IO;

const test_data_f: string = "/home/buddha314/datasets/yummly/test.json",
      train_data_f:string  = "single_recipe.json";

writeln("let's load some json, shall we?");

record Recipe {
  var cuisine: string,
      id: int,
      ingredients: [1..1] string;
}

var f = open(train_data_f, iomode.r);
var r = f.reader();
var final : Recipe;
r.readf("%jt\n", final);
writeln(final);

我显然不会先验地知道成分的数量,所以我尝试了ingredients: [1..1] string;行无济于事。在弄乱它之后,我无法让它工作。

使用 'list' 应该有效:

http://chapel.cray.com/docs/1.15/modules/standard/List.html

var ingredients : list(string);