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)