Register Business Object with nested objects as JToken

Stimulsoft Reports.NET discussion
Ruslan Kadyrbaev
Posts: 15
Joined: Mon Aug 31, 2020 9:19 am

Re: Register Business Object with nested objects as JToken

Post by Ruslan Kadyrbaev »

Lech Kulikowski wrote: Sat Oct 17, 2020 5:35 pm Hello,

We work hard on this problem and do our best to do it as fast as possible. We will let you know when the solution is available.

Thank you.
#2871
Hi all,

Is there any update? It is really important
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Register Business Object with nested objects as JToken

Post by Lech Kulikowski »

Hello,

We work hard on this problem and do our best to do it as fast as possible. We will let you know when the solution is available.

Thank you.
Antonin H.
Posts: 6
Joined: Fri Jan 03, 2025 3:23 pm

Re: Register Business Object with nested objects as JToken

Post by Antonin H. »

Hello,
I would like to revive this old thread, because I am getting the exact error described above in very much the same situation.

On my backend, I have nested json data delivered as string that I need to insert as business objects.
I use the strategy originally described above to create nested business objects based on a JToken definition. Here is a snippet of how I prepare my report before compilation:

Code: Select all

        public void LoadDataIntoReport(StiReport report, string jsonStringData, string businessObjectName)
        {
            var dataToken = Stimulsoft.Base.Json.Linq.JToken.FromObject(jsonStringData);
            report.RegBusinessObject(businessObjectName, dataToken.ToList()); // Without the "toList()" call the generation behaves inconsistenly and warns of ambiguous businessobject columns
            report.Dictionary.SynchronizeBusinessObjects(2); // This line throws an unhandled exception
        }
The error I am currently getting is this (same as in previous posts on this thread):

Code: Select all

System.NullReferenceException: Object reference not set to an instance of an object.
         at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetColumnsFromITypedList(ITypedList typedList)
         at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetColumnsFromObject(Object value)
         at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetColumnsFromData(Object data, Boolean includeChildDataSources)
         at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetColumnsFromData(Object data)
         at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeColumns(Object data, StiBusinessObject source)
         at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeColumns(StiBusinessObjectData data, StiBusinessObject source)
         at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeBusinessObjects()
         at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeBusinessObjects(Int32 maxLevel)
On flat data (or data on the top level of the nested json) this code works fine, but without the call to synchronize business objects, nested data is of course not included.

Upon closer inspection (and a peek into the call stack via Visual Studio), I can see where in Stimulsoft the exception occured:


Image


Is there a known way to get around this or an upcoming bugfix?

Thank you in advance for more information on the topic and have a nice day.
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Register Business Object with nested objects as JToken

Post by Lech Kulikowski »

Hello,

Please send us your request with a detailed description on support@stimulsoft.com.

Thank you.
Post Reply