When using JsonDataSource in LINQ Reporting engine, is there any supported way to iterate over a JSON object and access both its property name (key) and property value?
Example JSON:
"node":{
"ingredientsPerLanguage": {
"001": "Apples",
"002": "Pommes"
}
}
}
We want to output:
001 Apples
002 Pommes
Is there any template syntax or workaround that allows iterating over the object and printing both key and value ?
@pgcentric
I cannot confirm version-specific behavior from the retrieved release notes/changelog/docs. Treat the following as a hypothesis.
You can bind JSON data to a template using JsonDataSource [2], but the available documentation does not describe a built‑in syntax for iterating over an object’s properties while also retrieving the property name (key). A typical workaround is to transform the JSON into a collection that can be iterated—e.g., a list of objects with key and value fields—and then bind that list to the template.
To help you further, could you share the exact template fragment you are using (for example, the MERGEFIELD or ${…} expression) and the version of Aspose.Words for Java you are working with? With that information I can verify whether any additional options are available.
@pgcentric
Please check this reply - it explains how to achieve your requirement. Please also note that the approach relies on internal implementation of JsonDataSource , which can be changed in the future, so using it is at your own risk.
Thanks. Since iterating JSON object properties (key/value pairs) is a common requirement, is there any plan to officially support direct iteration over JSON objects in the LINQ Reporting Engine in the future?