MSON用于描述蓝图中的对象属性

时间:2015-07-31 18:07:25

标签: apiblueprint apiary.io apiary mson

我遇到类似于here所述的问题。

我有一个看起来像这样的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)

任何人的想法? 任何意见都将受到高度赞赏。

1 个答案:

答案 0 :(得分: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)

请注意,您可以将数组的示例值设置为以逗号分隔的列表,并且通常无需在类型为stringobject时明确说明(除非它没有名称) )。对于attributes对象,您可以直接将密钥放在其上,无需使用+ (object)

创建另一个级别

希望这有帮助!