Created
November 13, 2015 23:07
-
-
Save vingkan/5a1b56b7fd88fb486fa6 to your computer and use it in GitHub Desktop.
To explain JSON compression and decompression.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is not to be confused with compression of files. | |
*/ | |
// Object in decompressed form: | |
var object = { | |
name: "Mohsin", | |
feelings: { | |
type: "happiness", | |
intensity: 10, | |
description: "I feel very happy today because I'm going to learn a lot and build cool things" | |
} | |
} | |
//Object in compressed form: | |
var data = { | |
name: "Mohsin", | |
type: "happiness", | |
intensity: 10, | |
description: "I feel very happy today because I'm going to learn a lot and build cool things" | |
} | |
/* | |
* EXPLANATION | |
* When your application is running, it is beneficial to have objects inside objects because it gives structure to the data and makes the code more readable. | |
* When reading from and writing to the database, this kind of hierarchy can be detrimental to load times and structures because your database "tree" will get horizontally wider. | |
* Thus, some programmers will convert data from uncompressed form to compressed form when sending to their database and vice versa when running the application. | |
* This can slightly improve storage capabilities and runtime speed. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment