Number rendering as a Date - Linq templating

Hi,
We are having an issue with a number being transformed to a date when using Aspose.Word

Our json is as follows:

[
"QtrTable": [
      {
         "Name": "From",
         "Year1": "Mar.2019",
         "Year2": "Mar.2020",
         "Year3": "Mar.2021",
         "Year4": "Mar.2022",
         "Year5": "Mar.2023"
      },
      {
         "Name": "To",
         "Year1": "Mar.2020",
         "Year2": "Mar.2021",
         "Year3": "Mar.2022",
         "Year4": "Mar.2023",
         "Year5": "Mar.2024"
      },
      {
         "Name": "Fund",
         "Year1": -1.41,
         "Year2": 5.25,
         "Year3": -3.32,
         "Year4": -3.7,
         "Year5": 1.99
      }
   ]
]

When we run the word document to output a pdf the β€œYear2” value in the 3rd object (5.25) outputs as β€œMay 2024”.

Would you be able to help identify the issue?

@pm11

Using of arrays of JSON objects with mixed-type properties is not officially supported by LINQ Reporting Engine: some cases may occasionally work, whereas others may not, which may lead to further complications. So, generally, we would recommend to get rid of an array of such objects and use separate objects instead.

If this is not possible, then, in this partcular case, disabling of parsing of date-time values should help. This can be done as follows:

ArrayList<String> formats = new ArrayList();

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.setExactDateTimeParseFormats(formats);
JsonDataSource dataSource = new JsonDataSource(..., options);

Instead of complete disabling, parsing of date-time values can be fine-tuned to include only necessary date-time formats instead. See Accessing JSON Data for more information.

Thanks Ivan,

We have added the date formats as you suggested and this solves the issue we were having.

On the same template we have a chart and the date format change has caused the x axis to become illegible (see attached). The axis type is set as a Date axis.
The json for the chart has the date value formatted as β€œ6/30/19”.

Does setting the dateTime formats not cascade to charts?

image - correct axis.PNG:

image (1).png:

@pm11

JsonDataLoadOptions affect loading of a whole JSON file. As mentioned in my previous comment, you can try setting date-time parse formats explicitly like this:

ArrayList<String> formats = new ArrayList();
formats.add("M/d/yy");

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.setExactDateTimeParseFormats(formats);
JsonDataSource dataSource = new JsonDataSource(..., options);
1 Like