Document assembly API does not accept JSON data source object with a single array property in Java

Assembly lib does not accept JSON data source object with a single array property.

When I try to run the MainClass.simpleJsonDS_Demo() I get the following error:

Exception: An error has been encountered at the end of expression ‘in managers]>’. Can not get the value of member ‘managers’ on type ‘class com.groupdocs.assembly.system.data.DataRowCollection’.

But if I add another property next to managers property no matter if I put it before or after the exception disappears.

To get the same scenario it is necessary to just change the ManagerData.json and change line 2619 removing the “managers” argument from the call to construct DataSourceInfo. Ex: DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource);

Data source:
Template:

SimpleDatasetDemo.docx (11.9 KB)
datasource.zip (418 Bytes)

1 Like

@john.mcqueide

We are investigating this issue with ticket ID ASSEMBLYJAVA-25. You’ll be notified in case of any further update.

@john.mcqueide

We’ve an update on ASSEMBLYJAVA-25. This is an expected behavior rather an issue. Here is a relevant quote from our docs:

In template documents, if a top-level JSON element is an array or an object having only one property of an array type, a JsonDataSource instance should be treated in the same way as if it was a DataTable instance.

Put simply, when managers is the only property of the JSON object used by the customer, the engine accesses this property rather than the object itself, which is expected.
However, if you want to use the same template and code for JSON objects of dynamic structure - with or without properties other than managers - then this is possible. And we are already working on it.

1 Like

The issues you have found earlier (filed as ASSEMBLYJAVA-25) have been fixed in this update.

Please note that to use the same template and code for JSON objects of dynamic structure - with or without properties other than managers - you can use the following code:

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.setAlwaysGenerateRootObject(true);
JsonDataSource dataSource = new JsonDataSource(…, options);


This message was posted using Bugs notification tool by ivan.lyagin.