❄️✨Ho-ho-holiday offer for new projects! Check out our pricing page.

Flexmonster error json data is invalid on test and production (intermittent) site but is fine on localhost

Answered
Deo Bernal asked on October 15, 2025

Getting "error json data is invalid" on test and production (production is intermittent, sometimes ok) site but is fine on localhost. I am connecting on the same database for test site and localhost.

There are around 131,768 rows of data in our test case.

I tried useStreamLoader: true but no luck.

Attached is a sample nested json data and the error message.

Additional Info:

Flexmonster version "flexmonster""2.9.79"

React version "react""17.0.2"

 

10 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster October 16, 2025

Hello, Deo!

Thank you for reaching out to us.

Kindly note that Flexmonster expects to receive flat JSON data in an array of objects or an array of arrays format. You can check the examples of supported JSON formats by the link.

We assume that you are using dataRootPath property when connecting Flexmonster to nested JSON data.
If our assumptions are correct, please note that this property is used to point out from which part of JSON file Flexmonster should read the data, and the data should be in the
supported JSON format.
For example, if we set the dataRootPath: "sampletestDetails", the data should look as follows:

{
//other properties
sampletestDetails: [ //array of data
{
"subtestId": 1,
"testName": "Name 1"
},
{
"subtestId": 2,
"testName": "Name 2"
}
]
}

Also, please note that dataRootPath property works only for JSON data that is loaded via the filename property and is up to 30 MB in size, and is not compatible with useStreamLoader. For other cases, we recommend flattening the JSON before loading it into Flexmonster.

If our assumptions are not correct, and you are not using dataRootPath property, please provide us with your report configurations, as the provided sample-nested-data.json is loaded successfully into Flexmonster on our side without dataRootPath property.

Looking forward to hearing from you.

Kind regards,
Solomiia

Public
Deo Bernal October 17, 2025

Yes we are not using dataRootPath.
Please see configuration attached.

Attachments:
configuration.txt

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster October 17, 2025

Hello, Deo!

Thank you for providing your report configuration.

Please note that when the dataSource.data property is used, the component expects the data to be already available when Flexmonster instance is created. If the data isn’t loaded yet and the data variable you are passing to Flexmonster contains anything other than a supported JSON array(e.g. a Promise, object, or function), Flexmonster will consider the provided data as an invalid JSON.

For the described case with approximately 130,000 rows of data, we recommend connecting the data via the filename property instead of loading it separately and passing it through dataSource.data. You can also enable the useStreamLoader: true when loading data via filename.

Hope you will find our answer helpful.

Kind regards,
Solomiia

Public
Deo Bernal October 19, 2025

Thanks Solomila, just to confirm I've added these 2 properties as per screenshot.

But before applying the changes needed for the filename property I will have to confirm the 'data' property as what we already have. That is after all necessary JSON data has loaded then I create the flexmonster instance.

Will update you on my progress.

Attachments:
useStreamLoader.png

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster October 20, 2025

Hello, Deo!

Thank you for the update.

Do not hesitate to ask if any further questions arise.

Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster November 4, 2025

Hello, Deo!

Hope you are doing well.

Just checking in to ask if you have any further questions about setting JSON data via the data/filename property.

Looking forward to hearing your feedback.

Kind regards,
Solomiia

Public
Deo Bernal 3 days ago

Hi Solomia, 

Thanks and sorry for the delay in response. 

I was able to implement the filename property and seems to work on 200k records, but the problem for 500k records the browser crashes, any suggestions?

I have these settings:

       report={{

          dataSource: useStreamLoader ? {
            type: 'json',
            filename: dataFileUrl, // Use filename for streaming
            mapping: mapping || undefined, 
          } : {
            type: 'json',
            data: processedData, // Use processed data instead of raw data
            mapping: mapping
          },
          formats: customFormats,
          conditions: customCondition,
          slice: {
            rows: slice_rows,
            expands: {
              expandAll: true
            },
            measures: measures
          },
          options: {
            expandExecutionTimeout: 60000, // Increased timeout for very large datasets (60 seconds)
            useStreamLoader: useStreamLoader, // Enable streaming loader
            grid: {
              title: title,
              type: reportType,
              showGrandTotals: showGrandTotal ? 'on' : 'off',
              grandTotalsPosition: 'bottom',
              showTotals: showIndividualTotal ? 'on' : 'off'
            },
            defaultDateType: 'date string',
            showAggregationLabels: false,
            // Performance optimizations for large datasets
            asyncDataLoading: useStreamLoader, // Enable async data loading
            asyncDataLoadingTimeout: 300000 // 5 minutes timeout for async loading
          }
        }}


Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster 2 days ago

Hello, Deo!

Thank you for getting back to us.

Kindly note that Flexmonster itself doesn't limit the data that can be loaded into the component. At the same time, because the data needs to be loaded and processed in the browser, the actual amount of data that will be handled smoothly depends on the browser's memory available on the user’s machine.

As general advice, we suggest providing smaller data slices at once, as they are loaded faster and are more convenient for people to process. For example, you can move some fields to the Report Filters area so the users can prefilter data they don't need at once. You can also preprocess data before loading it to Flexmonster.

Our team has also reviewed the provided report and kindly suggests looking at the following points:

- useStreamLoader: to enable the stream loader, please use the useStreamLoader: true option in the dataSource object as follows:

dataSource: useStreamLoader ? {
type: 'json',
useStreamLoader: true, // need to be set in the dataSource object
filename: dataFileUrl, // Use filename for streaming
mapping: mapping || undefined,
} : {
type: 'json',
data: processedData, // Use processed data instead of raw data
mapping: mapping
},

- expandAll : for better performance, we recommend expanding the necessary nodes manually instead of using the expandAll function

- options as asyncDataLoading and asyncDataLoadingTimeout are not present in our options list: https://www.flexmonster.com/api/options-object/.

Hope you will find our answer helpful. Feel free to ask if there are any further questions.

Kind regards,
Solomiia

 

Public
Deo Bernal 2 days ago

Hi Solomia,

I added useStreamLoader: true and removed expandAll  that seems to load all 645,991 records.

I just have one more question for Flexmonster requests via filename, can it include the Authorization header? Currently I've checked your option list and cannot find any. I'm trying to find a way to make it secure, any suggestions?

 

Regards,

Deo

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster 10 hours ago

Hello, Deo!

Thank you for your quick response.

We are happy to hear that the stream loader works well for you.

Regarding your question about authorization headers, it is possible to send the custom request headers with the dataSource.requestHeaders property: https://www.flexmonster.com/api/data-source-object/#requestheaders. The key: value pairs specified in this property will be included in the data request.

Hope it helps. Feel free to ask if any further questions arise.

Kind regards,
Solomiia

Please sign in or register to submit your answer