Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Can I simply change the extension of a .json file to .txt without problems?

My CMS' file permissions lock access to files with the .json extension. These permissions can't be changed right now. To get around this and still use javascript objects I've changed the extensions of my .json files to .txt. So far so good.

Is this a reasonable solution or should I be worried about some unknown catastrophe in the future?

  • In the past I've also been able to load cross-domain .txt files using JSONP so I thought these two file formats might be fairly similar in storing js objects.
like image 389
Mark Duiker Avatar asked Feb 23 '15 18:02

Mark Duiker


People also ask

Is JSON the same as txt?

txt is a publisher focused initiative, sellers. json is an opportunity for supply-side platforms (SSPs) and exchanges to bring further transparency to the ecosystem. Similar to ads. txt, sellers.

Why is JSON widely used when coding in JavaScript rather than other data formats?

JSON is a wildly successful way of formatting data for several reasons. First, it's native to JavaScript, and it's used inside of JavaScript programs as JSON literals. You can also use JSON with other programming languages, so it's useful for data exchange between heterogeneous systems. Finally, it is human readable.

Are JSON files text files?

JSON (JavaScript Object Notation) is a data-interchange format that is human-readable text and is used to transmit data, especially between web applications and servers.

Which of the following is a reason to use JavaScript Object Notation JSON files for storing data?

JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa).


1 Answers

Can I simply change the extension of a .json file to .txt without problems?

Yes.

Think about it; the sole purpose of file extensions is to let a file browser (Windows Explorer, Finder Windows) choose a program to open that file with.

By default, .html files are opened (for me) with chrome, and chrome does a great job of displaying it as a web page - but, if I renamed the extension .42ftw, the data within the file wouldn't change, and I could still render it as html using chromium if I wanted - it's just my File Browser wouldn't know what to do with it.

So, basically, file extensions don't change the within data.

So, as long as you handle the data within your .txt files as you did with your .json files, you should see no difference. Maybe external packages you use might be configured to load only .json, but that shouldn't be a problem.

like image 80
theonlygusti Avatar answered Oct 06 '22 18:10

theonlygusti