Leading zero are omitted

Aspose word Link reporting engine, I am reading below input json from jsondatasource and when i print same using template syntax the leading zero from phone number is omitted. end result is only
Output:
813727511

Input:

"phones": [
{
    "id": 9912,
    "phoneNumber": "0813727511",
    "contactTypeCode": "M",
    "contactTypeDesc": "Mobile Phone",
    "ext": null,
    "primaryPhone": true,
    "countryCode": null
}
]

@Sangamesh019 By default upon loading JsonDataSource Aspose.Words uses JsonSimpleValueParseMode.LOOSE. In this mode types of JSON simple values are determined upon parsing of their string representations. For example, the type of β€˜prop’ from the JSON snippet { prop: β€œ123” } is determined as integer in this mode. So in your case value of "phoneNumber": "0813727511" is determined as 813727511 integer.
So in your case you should use JsonSimpleValueParseMode.STRICT. In this mode types of JSON simple values are determined from JSON notation itself, i.e. β€˜{ prop: β€œ123” }’ is determined as string.
Please try using the following code:

JsonDataLoadOptions opt = new JsonDataLoadOptions();
opt.setSimpleValueParseMode(JsonSimpleValueParseMode.STRICT);
JsonDataSource data = new JsonDataSource("C:\\Temp\\data.json", opt);
    
Document doc = new Document("C:\\Temp\\in.docx");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, data, "phones");
doc.save("C:\\Temp\\out.docx");

thank you for the details

1 Like