Assuming I have the following document structure:
{
"name": "myProduct",
"perspectives" : [
{
"name": "p1",
"views" : [
{
"name": "v1"
},
{
"name": "v2"
}
]
},
{
"name": "p2",
"views" : [
{
"name": "v1"
},
{
"name": "v2"
}
]
}
]
}
How would I go about updating the document structure to add an "alias" field to each of the views?
Basically I'm looking to do something like perspectives.views.alias: "av1" for all perspectives.views.name: "v1".
The resulting structure would look like this:
{
"name": "myProduct",
"perspectives" : [
{
"name": "p1",
"views" : [
{
"name": "v1",
"alias": "av1"
},
{
"name": "v2",
"alias": "av2"
}
]
},
{
"name": "p2",
"views" : [
{
"name": "v1",
"alias": "av1"
},
{
"name": "v2",
"alias": "av2"
}
]
}
]
}
To clarify, I'd like to do something like this:
foreach (view in product.perspectives.views)
{
if (view.name == "p1")
view.add("alias", "av1");
}