Design

Loop over object properties

Repeat any part of your document from object properties
COMMUNITY FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v3.0+ 

Iterate over object properties

data
  {
    "myObject" : {
      "paul" : "10",
      "jack" : "20",
      "bob"  : "30"
    }
  }
template
People namePeople age{d.myObject[i].att}{d.myObject[i].val}{d.myObject[i+1].att}{d.myObject[i+1].val}
Carbone Merge Icon
result
People namePeople agepaul10jack20bob30

Read and loop over the same object

To print a property of an object directly, such as {d.myObject.paul}, and also loop over the same object with {d.myObject[i].att} in the same template, add the pre-release tag {o.preReleaseFeatureIn=5004002} to the template. Without it, the generation fails. See all pre-release tags.

data
  {
    "myObject" : {
      "paul" : "10",
      "jack" : "20",
      "bob"  : "30"
    }
  }
template
{o.preReleaseFeatureIn=5004002}Paul is {d.myObject.paul} years old.People namePeople age{d.myObject[i].att}{d.myObject[i].val}{d.myObject[i+1].att}{d.myObject[i+1].val}
Carbone Merge Icon
result
Paul is 10 years old.People namePeople agepaul10jack20bob30