Generate Word Documents (Reports) from Templates using JSON Data Source in C# .NET | LINQ Reporting Engine | DataRow

I have a problem when json contains several different objects on top level.
I know that if a top-level JSON element represents an object, a JsonDataSource instance should be treated in template documents in the same way as if it was a DataRow instance,
but in this case I can use in template only properties from first object in Json.

I am trying to use a json that looks like this:

{
"FirstPart": {
	"FirstTag": "FirstValue",
	"SecondTag": "SecondValue"
},
"SecondPart": {
	"FirstUsername": "User",
	"SecondAge": 5
}
}

my template.docx :

FirstPart.FirstTag: <<[ds.ā€FirstTagā€]>>
FirstPart.SecondTag: <<[ds.ā€SecondTagā€]>>
SecondPart.FirstUsername: <<[ds.ā€FirstUsernameā€]>>
SecondPart.SecondAge: <<[ds.ā€SecondAgeā€]>>

and results looks like this:

FirstPart.FirstTag: FirstValue
FirstPart.SecondTag: SecondValue
SecondPart.FirstUsername: 
SecondPart.SecondAge: 

but i am expecting the following result

FirstPart.FirstTag: FirstValue
FirstPart.SecondTag: SecondValue
SecondPart.FirstUsername: User
SecondPart.SecondAge: 5

If the template contained a simple field at the top level, then I would be able to correctly access all properties using the name of the parent object:

{
"FirstPart": {
	"FirstTag": "FirstValue",
	"SecondTag": "SecondValue"
},
"SecondPart": {
	"FirstUsername": "User",
	"SecondAge": 5
},
"ThirdData": 11
}

with template

FirstPart.FirstTag: <<[ds."FirstPart".ā€FirstTagā€]>>
FirstPart.SecondTag: <<[ds."FirstPart".ā€SecondTagā€]>>
SecondPart.FirstUsername: <<[ds."SecondPart".ā€FirstUsernameā€]>>
SecondPart.SecondAge: <<[ds."SecondPart".ā€SecondAgeā€]>>

returns the result as expected:

FirstPart.FirstTag: FirstValue
FirstPart.SecondTag: SecondValue
SecondPart.FirstUsername: User
SecondPart.SecondAge: 5

How in the first case can I access the fields of the second object? What am I missing?

In the attachment simple .Net Core console app with this case and input Json, input template docx, output result docx and expected docx.

AsposeTest.zip (197.5 KB)

@asposeuuups,

We have managed to reproduce this problem on our end and logged it in our issue tracking system with ID WORDSNET-21443. We will further look into the details of this problem and will keep you updated on the status of linked ticket. We apologize for your inconvenience.

1 Like

@asposeuuups,

We have good news for you i.e. WORDSNET-21443 has now been resolved. The fix of this issue will be included in the next 21.1 version of Aspose.Words. We will inform you via this forum thread as soon as next 21.1 version containing the fix of this issue will be released at the start of next month. Please make sure that you use the second template that you shared earlier, namely:

FirstPart.FirstTag: <<[ds."FirstPart".ā€FirstTagā€]>>
FirstPart.SecondTag: <<[ds."FirstPart".ā€SecondTagā€]>>
SecondPart.FirstUsername: <<[ds."SecondPart".ā€FirstUsernameā€]>>
SecondPart.SecondAge: <<[ds."SecondPart".ā€SecondAgeā€]>>

Also, the double quotes are redundant in this case.

1 Like

Great news, thanks.

The issues you have found earlier (filed as WORDSNET-21443) have been fixed in this Aspose.Words for .NET 21.1 update and this Aspose.Words for Java 21.1 update.