LINQ Reporting Engine - Unable to access property of child array objects within an array of JSON objects

Following is a sample of json object created:
{
“Domain”: {
“Title”: “Introduction”,
“RiskScore”: null,
“ScoreFooter”: null,
“Chart”: null,
“ChartText”: null,
“Area”: [
{
“Title”: “Purpose”,
“RiskScore”: null,
“ScoreFooter”: null,
“SubDomain”: null
}
]
}
},

Am using the following code in the template file to access the property Title of an Area child object whose value is Purpose as given above.

1.1

<<foreach [in domains]>> <<if [IndexOf() == 0]>> <<foreach [in domain.Area]>>
 <<if [IndexOf() == 0] >> <<[domain.area.Title]>> <</if>> <</foreach>> <</if>> <</foreach>>

This works. However, when I try to access the same property of another Area object in the array, I am unable to access it. I receive the follwowing error:
“An error has been encountered while evaluating the expression or statement ‘domain.Area.Title]>’. A single child data row is expected, but multiple child data rows are found.”
Kindly help me solve this issue.

Edit: in the template code above, the closing tags aren’t being displayed properly even though I did write them down in my post

@ashlosh

Unfortunately, using the details provided, we cannot reproduce the issue. Could you please share the complete JSON object (it seems that you shared just a part according to the template), as well as the template causing the issue? Providing code (including options you use for loading JSON) would be also great.

@ashlosh

As an assumption, <<[domain.area.Title]>> in your template should be replaced with just <<[Title]>>. If this does not work, please share more details as per my previous comment. Thanks.

@ivan.lyagin
Hi,

So, I want to use the title property in an isolated manner. Use just that in a specific place, and not in a loop. So, for that, I am using the IndexOf () method to determine which array object should be identified.
Please find below the enitre json file content:-
[
{
“Domain”: {
“Title”: “Introduction”,
“RiskScore”: null,
“ScoreFooter”: null,
“Chart”: null,
“ChartText”: null,
“Area”: [
{
“Title”: “Purpose”,
“RiskScore”: null,
“ScoreFooter”: null,
“SubDomain”: null
}
]
}
},
{
“Domain”: {
“Title”: “Executive Summary”,
“RiskScore”: null,
“ScoreFooter”: null,
“Chart”: null,
“ChartText”: null,
“Area”: null
}
},
{
“Domain”: {
“Title”: "RealRisk Score ",
“RiskScore”: “27”,
“ScoreFooter”: “RealRisk, May 2023”,
“Chart”: [
{
“Field”: “Governance”,
“Value”: “27”
},
{
“Field”: “People & Processes”,
“Value”: “25”
},
{
“Field”: “Protection”,
“Value”: “22”
},
{
“Field”: “Preparedness & Response”,
“Value”: “16”
},
{
“Field”: “Detection”,
“Value”: “11”
},
{
“Field”: “Application & Prodcut Security”,
“Value”: “44”
}
],
“ChartText”: “Figure 1: RealRisk scores by assessment Domain”,
“Area”: null
}
},
{
“Domain”: {
“Title”: “Area Findings”,
“RiskScore”: null,
“ScoreFooter”: null,
“Chart”: null,
“ChartText”: null,
“Area”: [
{
“Title”: “Governance”,
“RiskScore”: “27”,
“ScoreFooter”: “Overall Real Risk, Governance”,
“SubDomain”: [
{
“Title”: “Program Ownership”,
“RiskScore”: “26”
},
{
“Title”: “Policies”,
“RiskScore”: “27”
},
{
“Title”: “Program Management”,
“RiskScore”: “28”
}
]
},
{
“Title”: “People & Processes”,
“RiskScore”: “27”,
“ScoreFooter”: “Overall Real Risk, People & Processes”,
“SubDomain”: [
{
“Title”: “Training & Awareness”,
“RiskScore”: “36”
},
{
“Title”: “User Behavior Testing & Analysis”,
“RiskScore”: “27”
},
{
“Title”: “Onboarding & Offboarding”,
“RiskScore”: “39”
},
{
“Title”: “Business Process Controls”,
“RiskScore”: “11”
}
]
},
{
“Title”: “Protection”,
“RiskScore”: “22”,
“ScoreFooter”: “Overall Real Risk, Protection”,
“SubDomain”: [
{
“Title”: “Technical Configuration Standards & Procedures”,
“RiskScore”: “8”
},
{
“Title”: “Change Control Management”,
“RiskScore”: “9”
},
{
“Title”: “Mobile Devices Management”,
“RiskScore”: “10”
},
{
“Title”: “Remote Access”,
“RiskScore”: “27”
},
{
“Title”: “Data Protection”,
“RiskScore”: “43”
},
{
“Title”: “Email Security”,
“RiskScore”: “13”
},
{
“Title”: “Identity Access Management”,
“RiskScore”: “17”
},
{
“Title”: “Privileged Access Management”,
“RiskScore”: “23”
},
{
“Title”: “Authentication”,
“RiskScore”: “17”
},
{
“Title”: “Endpoint Protection”,
“RiskScore”: “11”
},
{
“Title”: “Patch Management”,
“RiskScore”: “31”
},
{
“Title”: “Physical & Environmental Security”,
“RiskScore”: “21”
}
]
},
{
“Title”: “Preparedness & Response”,
“RiskScore”: “16”,
“ScoreFooter”: “Overall Real Risk, Preparedness & Response”,
“SubDomain”: [
{
“Title”: “Business Impact Analysis”,
“RiskScore”: “8”
},
{
“Title”: “Backups”,
“RiskScore”: “11”
},
{
“Title”: “Business Continuity Planning”,
“RiskScore”: “16”
},
{
“Title”: “Incident Response”,
“RiskScore”: “32”
},
{
“Title”: “Disaster Recovery”,
“RiskScore”: “18”
},
{
“Title”: “Cyber Insurance”,
“RiskScore”: “19”
}
]
},
{
“Title”: “Detection”,
“RiskScore”: “11”,
“ScoreFooter”: “Overall Real Risk, Detection”,
“SubDomain”: [
{
“Title”: “Threat Intelligence & Monitoring”,
“RiskScore”: “3”
},
{
“Title”: “Vulnerability Management”,
“RiskScore”: “5”
},
{
“Title”: “Logging”,
“RiskScore”: “39”
},
{
“Title”: “Penetration Testing”,
“RiskScore”: “31”
}
]
},
{
“Title”: “Application & Product Security”,
“RiskScore”: “44”,
“ScoreFooter”: “Overall Real Risk, Application & Product Security”,
“SubDomain”: [
{
“Title”: “Ownership”,
“RiskScore”: “31”
},
{
“Title”: “Policy and Process”,
“RiskScore”: “55”
},
{
“Title”: “Developer Support for Secure Development”,
“RiskScore”: “17”
},
{
“Title”: “Security by Design”,
“RiskScore”: “19”
},
{
“Title”: “Product and Development Environment Controls”,
“RiskScore”: “58”
},
{
“Title”: “Testing”,
“RiskScore”: “7”
}
]
}
]
}
}
]

@ashlosh

Unfortunately, using the provided JSON data and previously provided template, I was not able to reproduce the issue. It would be ideal, if you shared a standalone console application reproducing the issue.

By the way, have you tried to use <<[Title]>> instead of <<[domain.area.Title]>> in your template as per my previous comment?

As a note, if your sole purpose is to output the title of the first domain area object, then you can shorten template syntax as follows: <<[domains.First().Area.First().Title]>> or <<[domains.ElementAt(0).Area.ElementAt(0).Title]>>.