I would like to create a nested array with objects in MSON format to use with API Blueprint and Apiary. I code looks correct but when I render it in Apiary I don't get the expected JSON.
Example I want to create: A navigation has multiple categories. Each category can have multiple subcategories. Each category and subcategory have a name.
The MSON I created for this:
FORMAT: 1A
# Test nested arrays-in-object-arrays
A navigation has multiple categories. Each category can have multiple subcategories.
# GET /navigation
+ Response 200 (application/json)
+ Attributes
+ categories (array)
+ (object)
+ name: Category One (string) - Name of the category
+ subcategories (array)
+ (object)
+ name: Sub category One (string) - Name of the subcategory
The output I would expect in JSON:
{
"categories": [
{
"name": "Category One",
"subcategories":
[
{
"name": "Sub category One"
}
]
}
]
}
The output I get in Apiary
{
"categories": [
{
"name": "Category One",
"subcategories": []
}
]
}
I was having difficulties with doing something similar. I ended up declaring the nested type as a data structure and referencing it like so:
Which produces: