2017-05-15 32 views
1

我一直在查看很多例子,但是我没有找到一种方法来指定一个属性,它的值是一个JSON对象,并以字符串作为值。我有一个对象是这样的:如何使用MSON/API蓝图中的字符串值指定JSON对象?

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

我挣扎于如何指定dynamic_attributes因为这些密钥是动态的,在写文档的时候不知道。它基本上是一个JSON对象,应该只有字符串作为值。

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

回答

0

我找到了解决方案,它被称为变量属性名称。我早些时候偶然发现了他们,但并不了解他们。

这里是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

相关问题