1

我有一个类似于这里描述的问题。

我有一个如下所示的 JSON:

{
  "photos": [
    {
      "key": "y37dmj10jkwof/moOIUB8912JKVgh",
      "caption": "A world of gamers.",
      "tags": [
        "game",
        "japan"
      ],
      "attributes": {
        "copyright": true,
        "use": [
          "public",
          "private"
        ]
      }
    }
  ]
}

我正在尝试使用 MSON 描述属性,以呈现蓝图。但是,我在这方面并不成功。这是我的尝试:

+ Attributes (required, object)
    + photos (required, array)
        + (object)
            + key (required, string) - Photo key
            + caption (required, string) - Photo caption
            + tags (required, array)
                + game (string)
                + japan (string)
            + attributes (required, object)
                + (object)
                    + copyright: true (required, boolean)
                    + uses (required, array)
                        + public (string)
                        + private (string)

任何人的想法?任何输入将不胜感激。

4

1 回答 1

1

这是一个我认为可以满足您要求的示例:

+ Attributes
    + photos (required, array)
        + (object)
            + key: y37dmj10jkwof/moOIUB8912JKVgh (required) - Photo key
            + caption: A world of gamers (required) - Photo caption
            + tags: game, japan (required, array)
            + attributes (required)
                + copyright: true (required, boolean)
                + use: public, private (required, array)

请注意,您可以将数组的示例值作为逗号分隔的列表放置,并且通常不需要明确说明类型何时为 astringobject(除非它没有名称)。至于attributes物体,直接把钥匙放在上面就可以了,不用再用+ (object)

希望这可以帮助!

于 2015-08-03T08:03:37.520 回答