3

I'm getting from client json string:

{ "Client": { "Name": "John" } }

And in document I have the following tag:

<<[client.name]>>

and try to inject it:

var obj = JsonConvert.DeserializeObject(input.DataJson);
var engine = new ReportingEngine();
engine.BuildReport(document, obj);

But it doesn't work. Can I inject that json with case insensetive checking of properties? Or I have to modify json to do its properties as lowercase? How can I do that?

A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82
  • You could deserialize to a fixed type rather than just parsing to a dynamic `JToken`. If you must use `JToken` then one of the techniques from [How to change all keys to lowercase when parsing JSON to a JToken](https://stackoverflow.com/q/40859805) and/or [Json.net rename properties](https://stackoverflow.com/q/11679804). – dbc Feb 01 '18 at 09:28

1 Answers1

4

I am afraid, LINQ Reporting Engine currently does not support dynamic objects as data sources. We have logged a new feature request for your scenario. The ID of this issue is WORDSNET-16421. We will inform you via this thread as soon as the requested feature is implemented. You may convert JSON string to DataSet to make it work as described in the following example:

// Assume you have following in document
// <<[Client.Name]>>
string json = "{ \"Client\": { \"Name\": \"John\" } }";

XmlDocument Xml = (XmlDocument)JsonConvert.DeserializeXmlNode(json);

DataSet ds = new DataSet();
ds.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(Xml.InnerXml)));

Document doc = new Document(MyDir + @"in.docx");

ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, ds.Tables[0].Rows[0], "Client");

doc.Save(MyDir + @"18.2.docx");

I work with Aspose as Developer Evangelist.

Awais Hafeez
  • 1,070
  • 5
  • 9
  • Thanks, let me know when it's ready here or get me a link to the issue, please. – A. Gladkiy Feb 02 '18 at 09:30
  • Unfortunately, there is no direct way to track issues by yourself. But, you are welcome to ask the issue status via this thread. We will verify the status from our internal issue tracking system and reply you back. We will be sure to inform you via this thread as soon as this issue is resolved. – Awais Hafeez Feb 06 '18 at 12:01