How to specify a JSON object with string values in MSON / API Blueprint?

1.2k views Asked by At

I have been looking through the examples a lot but I didn't find a way to specify a property whose value is a JSON object with strings as values. I have an object like this:

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

I'm struggling on how to specify the dynamic_attributes because the keys are dynamic and not known at the time of writing the documentation. It's basically a JSON object which should only have strings as values.

Is there a way to do this in MSON?

1

There are 1 answers

0
user1915201 On

I found the solution and it is called Variable Attribute Names. I stumbled upon them earlier but didn't understand them.

Here is the 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

See MSON Specification for variable property name