Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sub-Properties are used when a regular property is a composite of other identifying properties. An example works well to illustrate:

Code Block
languagejs
themeConfluence
{
   "shipping":{
      "address":"6649 N Blue Gum St",
      "city":"New Orleans",
      "county":"Orleans",
      "state":"LA",
      "zip":"70116"
   }
}

...

Developers are not required to use sub-properties. In the above example, each of the sub-properties could have been regular properties in the resource object. However, let's suppose there are different types of addresses in the resource object. We'll use mailing and shipping. If both types of addresses were represented by regular properties then the resource object might look like this:

noformat
Code Block
languagejs
{
   "mailingAddress":"PO Box 1234",
   "mailingCity":"New Orleans",
   "mailingCounty":"Orleans",
   "mailingState":"LA",
   "mailingZip":"70116",
   "shippingAddress":"6649 N Blue Gum St",
   "shippingCity":"New Orleans",
   "shippingCounty":"Orleans",
   "shippingState":"LA",
   "shippingZip":"70116"
}
{
   "mailingAddress":"PO Box 1234",
   "mailingCity":"New Orleans",
   "mailingCounty":"Orleans",
   "mailingState":"LA",
   "mailingZip":"70116",
   "shippingAddress":"6649 N Blue Gum St",
   "shippingCity":"New Orleans",
   "shippingCounty":"Orleans",
   "shippingState":"LA",
   "shippingZip":"70116"
}

This isn't horrible, but we might consider that sub-properties help to make this look better and help it to be better organized:

noformat
Code Block
language
js
{
   "mailing":{
      "Address":"PO Box 1234",
      "City":"New Orleans",
      "County":"Orleans",
      "State":"LA",
      "Zip":"70116"
   },
   "shipping":{
      "Address":"6649 N Blue Gum St",
      "City":"New Orleans",
      "County":"Orleans",
      "State":"LA",
      "Zip":"70116"
   }
}

...