I have a JSON file that looks something like this:
{
"Parent":{
"123":{
"Name": "Paul"
}
}
}
I would normally would use "<<[Parent.123.Name]>>"
which is fine, but how can I access 123 using a variable/ other elements in the JSON. Exampe `"<<[Parent[ChildId].Name]>>
@pphillipsbiz
To access members which names do not conform C# restrictions imposed on class/member names, double quotes should be used for escaping as shown in the following snippet:
JsonDataSource dataSource = ...
DocumentBuilder builder = new DocumentBuilder();
builder.Write("<<[Parent.\"123\".Name]>>");
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(builder.Document, dataSource, "Parent");
To clarify, when creating a template manually rather than by code, its syntax should be as follows:
<<[Parent."123".Name]>>
Thanks.
I have a variable called ProductCode
(stored in JSON), I want to reference this variable within the linq statement like Parent.[ProductCode].FieldValue. [ProductCode] = Json Element
.
@pphillipsbiz
Could you please share the complete JSON file, so we could better understand the scenario?
Thank you, I have found a workaround to the problem.