【问题标题】:How to specify a JSON object with string values in MSON / API Blueprint?如何在 MSON / API 蓝图中使用字符串值指定 JSON 对象?
【发布时间】:2017-05-15 08:31:29
【问题描述】:

我一直在浏览这些示例,但我没有找到一种方法来指定一个属性,该属性的值是一个以字符串为值的 JSON 对象。我有一个这样的对象:

{
  id: 123,
  title: "I am a title",
  dynamic_attributes: {
    "key1": "value1",
    "key2": "value2",
    "keyN": "valueN",
  }
}

我正在为如何指定 dynamic_attributes 苦苦挣扎,因为键是动态的,在编写文档时还不知道。它基本上是一个 JSON 对象,应该只有字符串作为值。

有没有办法在 MSON 中做到这一点?

【问题讨论】:

    标签: apiblueprint apiary mson


    【解决方案1】:

    我找到了解决方案,它被称为变量属性名称。我之前偶然发现了它们,但不理解它们。

    这是 MSON:

    # Entity (object)
    
    ## Properties
    
    + id: `12` (integer,required) - The ID of this entity.
    + dynamic_attributes (AttributeValue) - Map of custom attribute values.
    
    # AttributeValue (object)
    
    ## Properties
    
    + *key1* (string) - Value for Key 1
    + *key2* (string) - Value for Key 2
    

    MSON Specification for variable property name

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-12
      相关资源
      最近更新 更多