This is a migrated thread and some comments may be shown as answers.

Kendo SaveAs removes whitespaces

6 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
arjun
Top achievements
Rank 1
arjun asked on 15 Mar 2018, 01:37 PM

Hi,

On the click of a button, I am saving the content (json) to a file. The problem I am facing is that the file has whitespaces stripped out.

saveContent : function () {
 var format = "data:application/json";
 var fileName = "content.json";
 var dataURI = format + "," + this.content;
 
 kendo.saveAs(
 {
   dataURI: dataURI,
   fileName: fileName
 }
);
}

For e.g. if the json is something like this

{"productDescription" : "Bag of wheat 15 kilogram"}

 

the content of file is the following. How can I make sure that saved file has whitespaces preserved?

{"productDescription" : "Bagofwheat15kilogram"}

6 Answers, 1 is accepted

Sort by
0
arjun
Top achievements
Rank 1
answered on 15 Mar 2018, 06:10 PM

Turns out, if its data:application/json, then it removes all the whitespaces.

If its data:text/plain, then it preserves the whitespaces.

0
Veselin Tsvetanov
Telerik team
answered on 19 Mar 2018, 07:33 AM
Hello Arjun,

Here you will find a small Dojo sample, which replicates the described scenario. You will notice, that the exported JSON properly preserves the white spaces in its values.

May I ask you to modify the above so it reproduces the issue observed at your end and send it back to us? This way we will be able to troubleshoot the problem locally and to provide you with the most appropriate assistance on this case.

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
reb
Top achievements
Rank 1
answered on 27 Mar 2018, 06:00 PM

Hi I have a similar problem.The issue is indentation apeears ok in visual studio but in editor it appears in a line with spaces 

0
Veselin Tsvetanov
Telerik team
answered on 29 Mar 2018, 08:51 AM
Hi Reb,

I am not quite sure if I understand correctly the issue faced. If case you are not seeing the proper indention in some specific text editor, note that it might be an application specific issue.

If this is not the case, could you please, prepare and send us a small Dojo sample replicating the problem? 

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
reb
Top achievements
Rank 1
answered on 29 Mar 2018, 02:01 PM

Hi ,

Is there a kendo UI element that I can use to display json file with indentation and even maybe that allows to collapse and expand sub elements.

Also is there a way to export to Json as we have export to PDF ?

 

Will share dojo example soon

0
Veselin Tsvetanov
Telerik team
answered on 02 Apr 2018, 09:03 AM
Hello Reb,

I am afraid that none of the Kendo widgets would allow you to load and display a JSON file. Nevertheless, you could write or paste a JSON formatted text in a Kendo Editor.

As per the export question, the Kendo Spreadsheet can perform such action. Nevertheless, a visualized JSON in an Editor widget could not be exported as JSON file.

In case you have any other questions, which are not directly related to the initial topic of the current thread ("Kendo SaveAs removes whitespaces"), I would recommend you to open a separate thread for each of them. This way we will be able to keep the thread focused and to provide you with the most appropriate assistance on each case.

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
arjun
Top achievements
Rank 1
Answers by
arjun
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
reb
Top achievements
Rank 1
Share this question
or