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
Turns out, if its data:application/json, then it removes all the whitespaces.
If its data:text/plain, then it preserves the whitespaces.
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
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
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
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
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