Are .txt and .json files equally good for storing javascript objects?

Is it possible to simply change the extension of a .json file to a .txt without problems?

Permissions for My CMS files block access to files with the .json extension. These permissions cannot be changed right now. To get around this and still use javascript objects, I changed the extensions of my .json files to .txt. So far so good.

Is this a smart decision or should I worry about some unknown disaster in the future?

  • In the past, I could also load cross-domain .txt files using JSONP, so I thought that these two file formats could be pretty similar when storing js objects.
+5
source share
1 answer

Is it possible to simply change the extension of a .json file to a .txt without problems?

Yes.

Think about it; the sole purpose of the file extension is to allow the file browser (Windows Explorer, Windows Finder) to select a program to open this file with.

By default .html files are open (for me) with chrome, and chrome does a great job of displaying it as a web page, but if I rename the extension .42ftw , the data in the file won't change, and I could still display it like html, using chrome, if I wanted to - it's just that my file browser did not know what to do with it.

Thus, basically file extensions do not change internal data.

So, as long as you process the data in your .txt files, as it was in your .json files, you will not see the differences. It is possible that the external packages you use can be configured to download only .json , but this should not be a problem.

+3
source

Source: https://habr.com/ru/post/1214022/


All Articles