Page History
If you have already learned how to add a property or a sub-property to a resource object, you already know the basics of how these GetObject companion services work. As one might expect, there is an AddSubResource service available to add a sub-resource to a resource. In fact, there are two principle services available to the developer. The other service is named AddSubResourceObject. Both of these are explained below.
Table of Contents |
---|
AddSubResource Service
The calling signature for the AddSubResource service is virtually identical to the AddSubProperties service (i.e., the plural version of the AddSubProperty service). The key difference is that when the AddSubProperties service is called more than once for the same parent property name and the same sub-property names, the new sub-property values replace the old ones. The AddSubResource service, on the other hand, adds (or appends) new sub-resource objects to the existing array of sub-resources associated with the parent property. Here is an example of what the code might look like:
...
Code Block | ||
---|---|---|
| ||
{
"contacts":[
{
"firstName":"Harrison",
"lastName":"Haufler"
},
{
"firstName":"Haydee",
"lastName":"Denooyer"
},
{
"firstName":"Heike",
"lastName":"Berganza"
},
{
"firstName":"Helga",
"lastName":"Fredicks"
},
{
"firstName":"Herman",
"lastName":"Demesa"
},
{
"firstName":"Herminia",
"lastName":"Nicolozakes"
},
{
"firstName":"Hillary",
"lastName":"Skulski"
},
{
"firstName":"Howard",
"lastName":"Paulas"
}
]
} |
...
} |