0
votes

Totally new to JSON/JSRender just trying something i believe to be simply but cannot find the answer for the life of me..

Im exporting the below data from a WEB API, and would like to render it using JSRender into a document. I am struggling to find out how to access the Child Object "employee" and retrieve the "id" value of 98765

I thought it would be something like {{employee_training.employee.id}} but this does not seem to work..

JSON Data

"employee_training": [
        {
            "id": 1234,
            "name": "Training Course Alpha",
            "start_on": "2019-07-02",
            "end_on": "2019-07-02",
            "status": "Completed",
            "outcome": "Passed",
            "notes": "",
            "employee": {
                "id": 98765
            }

        }
]
1

1 Answers

0
votes

The following will iterate over the employee_training array and output the list of employee ids.

{{for employee_training}}
  {{:employee.id}}
{{/for}}

See https://www.jsviews.com/#fortag@array and https://www.jsviews.com/#assigntag.