Data Server JSON

Answered
Scott Oliver asked on July 30, 2021

Hello,
We have noticed a discrepancy between the way that data server and your local client process JSON.
 
When parsing the data to a local version, the following JSON works perfectly fine:
 

var jsonData =
[
{
'Color' : 'green',
'Country' : 'Canada',
'State' : 'Ontario',
'City' : 'Toronto',
'New' : 'Field',
'Price' : 174,
'Quantity' : 22
},
{
'Color' : 'red',
'Country' : 'USA',
'State' : 'California',
'City' : 'Los Angeles',
'Price' : 166,
'Quantity' : 19
}
];

 
However, flex data server rejects this for the following two reasons:

  • Quotations must be of the double variety ("such as this" and 'not this')
  • The first packet of JSON must include all of the fields that will be used throughout

Unfortunately for our use case, the second point is not an option (the first is just an annoyance). Is there any way that we can work around this issue?

12 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 30, 2021


Hello, Scott,
 
Thank you for reaching out to us.
 
Concerning quotation, please note that JSON requires using double quotes according to the specification. Single quotes and unquoted strings can only be used when operating with inline JSON in scripts.
 
Talking about the first packet, it requires all the fields to be present. The first entry is used to construct the internal structure of the data set and resolve fields' data types.
When connecting directly to JSON, fields absent in the first entry will be ignored as well: https://jsfiddle.net/flexmonster/t743fpkj/ (the "New" field is not displayed in the Field List).
We have moved the "New" field from your example to the second element of the array. Otherwise, the mentioned dataset loads normally both directly and using the Data Server.
 
We hope it helps.
Feel free to contact us if other questions arise.
 
Kind regards,
Illia

Public
Scott Oliver July 30, 2021

Unfortunately, this does not solve our problem, as we cannot store all of the information in all of the elements. The first element may miss particular objects that are present in the following elements. This is where we would prefer to use the JSON header, but I presume this is not compatible with data server?

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 30, 2021

Hello,
 
Thank you for your feedback.
 
You are right about the fact that the header JSON object is not supported for the Data Server.
However, please note that you do not need to store all the information in all of the elements. Similar to the mentioned header object, it is enough to mention all available fields in the first object of the data set.
 
Do not hesitate to contact us if other questions arise.
 
Kind regards,
Illia

Public
Scott Oliver August 6, 2021

Yes, however, if we were to include a blank element (where all of the objects had been noted but set to empty values), this would still be parsed into the report, and show blank values for all columns.

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 6, 2021

Hello, Scott,
 
This is due to the fact that Flexmonster Data Server uses values of the first record to identify the data type of the corresponding field. This datatype will be applied to the following records across the dataset.
 
In its turn, an empty value does not provide any information about the nature of the field. As a result, the Data Server is unable to predict the field's type and ignores it.
 
Please let us know if other questions arise.
 
Kind regards,
Illia

Public
Scott Oliver June 1, 2022

Hi Illia,
 
Any news on this being updated? As you can imagine, not all of our data has values for all of the fields.
 
It would be great to use the mapping header, as with the Flexmonster client.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 2, 2022

Hello, Scott!

Thank you for writing to us.
 
We agree that having a mapping equivalent for Flexmonster Data Server sounds reasonable and would be more convenient. For now, this feature is on our customer's wishlist. Our team will consider it when planning future Data Server improvements.
We will notify you in case of any updates on the matter.
 
Feel free to contact us in case of any other questions.

Regards,
Solomiia

Public
Scott Oliver September 7, 2022

Hello, I don't suppose there is any news on whether or not you have resolved this?

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 8, 2022

Hello, Scott!

Thank you for writing to us.
 
For now, we do not have any news regarding this improvement.
We understand that this feature would be a great help for your use case. However, our roadmap is full at the moment. 
 
Your request is on our customer's wishlist, and we will surely notify you about any updates.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 21, 2023

Hello, Scott!
 
Hope you are having a great week.
 
Our team is glad to inform you that the new Mapping configuration is now available for the Flexmonster Data Server.
Now mapping can be configured via UI using Flexmonster Admin Panel after creating the CSV or JSON index. The new Mapping property would appear on the Index Details page. It allows choosing the data type from string, number, and date.
The mapping for the Data Server could also be configured in the flexmonster-config.json file as follows: https://www.flexmonster.com/doc/configurations-reference/#mapping.
 
The Mapping feature in Flexmonster Data Server is available in the 2.9.45 version of Flexmonster: https://www.flexmonster.com/release-notes/version-2-9-45/.
Here is our updating guide for reference: https://www.flexmonster.com/doc/updating-to-the-latest-version/. Kindly note that the Data Server and pivot component should both be updated.
 
Please let us know if the feature works well for you.
Looking forward to hearing your feedback.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 28, 2023

Hello, Scott!

Hope you are doing well.

Our team is wondering if you had some time to test the new Mapping feature in the Data Server. Could you please let us know if it works well for you?

Looking forward to your feedback.

Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster March 14, 2023

Hello, Scott!

Hope you are having a great week.

Just checking in to ask if the new Mapping feature in the Data Server works well for you.

Looking forward to hearing from you.

Kind regards,
Solomiia

Please login or Register to Submit Answer