LINQ Reporting Engine - JsonDataSource replacing Whitespace

Hi,

I’ve been having a problem using the ReportingEngine where whitespace is being removed from my output document and think I have narrowed it down to the JsonDataSource.

I have provided some C# code below which should demonstrate the issue.

The code outputs 2 documents, one which uses the JsonDataSource and one which uses DataSourcesNames/DataSources. I pass the same values to both of them, but when the JsonDataSource is used it seems to strip out the whitespace completely.

Json Output

Other Output

var reportingEngine = new ReportingEngine();

var doc = new Document();
doc.EnsureMinimum();

var builder = new DocumentBuilder(doc);
builder.MoveToDocumentStart();
builder.Write("LINE BEFORE");
builder.InsertParagraph();
builder.Write("<<[LineWhitespace]>>");
builder.InsertParagraph();
builder.Write("<<[BlockWhitespace]>>");
builder.Write("LINE AFTER");

// JSON
var jsonDoc = doc.Clone();

var json = "{" +
           "    \"LineWhitespace\" : \"    \"," +
           "    \"BlockWhitespace\" : \"\r\n\r\n\r\n\r\n\"" +
           "}";

var jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
var jsonDataSource = new JsonDataSource(jsonStream, new JsonDataLoadOptions { SimpleValueParseMode = JsonSimpleValueParseMode.Strict });
jsonStream.Dispose();

reportingEngine.BuildReport(jsonDoc, jsonDataSource);

var jsonFileName = Path.GetTempPath() + "Json.docx";
jsonDoc.Save(jsonFileName);

System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(jsonFileName) { UseShellExecute = true });

// OTHER
var otherDoc = doc.Clone();
var otherDataSources = new object[] { "     ", "\r\n\r\n\r\n\r\n" };
var otherDataSourceNames = new string[] { "LineWhitespace", "BlockWhitespace" };

reportingEngine.BuildReport(otherDoc, otherDataSources, otherDataSourceNames);

var otherFileName = Path.GetTempPath() + "Other.docx";
otherDoc.Save(otherFileName);

System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(otherFileName) { UseShellExecute = true });

@James_Winn
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25677

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@James_Winn

After Aspose.Words 23.8 is released, you will be able to instruct LINQ Reporting Engine to preserve leading and trailing whitespaces for JSON string values (which are trimmed by default) as follows:

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

The issues you have found earlier (filed as WORDSNET-25677) have been fixed in this Aspose.Words for .NET 23.8 update also available on NuGet.