Serialization & Deserialization - Transporting spiderman

Serialization & Deserialization - Transporting spiderman

The Journey To Gwen Stacy

🕸️The Kingpin! teleported through the poral to destroy the world . Miles want to contact Gwen in another dimension to tell her about kingpin! . But he have no idea How to go through the portal and warn Gwen and save their dimension .🕸️

[Pasted image 20250213204344.jpg]

[Pasted image 20250213204421.jpg]

🕸️Let us help miles to go through the portal to contact Gwen , so that we together could save the world together .🕸️

📜 Chapter 1: Why we need Serialization & Deserialization ?

🕷️If we try to send miles directly through the portal , The other dimension may not accept Miles , as the other part of the dimension may not know if it is a Human or else . So we have to make sure that the body of Miles does not get destroyed .🕷️

🕷️For that to happen we must use a Universal rule for all the portals , so that if we send any message or object it must get there as we have sent it . It must not get Destroyed.🕷️

📜 Chapter 2: Why is Serialization ?

🕷️In Sending and receiving message we have may techniques , most popular among them are JSON and XML . We will use JSON to teleport Miles .🕷️

  • 🕷️what is JSON ?

  • 🕷️JSON (JavaScript Object Notation) is a lightweight data format used for storing and exchanging data between a server and a client. It is easy to read and write for humans and easy for machines to parse.

🕸️Now Let us convert Miles to JSON and send him through the portal :

const user = {
name: "Miles",
age: 18,
city: "New York",
work:"Spiderman"
};
// Convert object to JSON string 
const serializedData = JSON.stringify(user); 
console.log(serializedData)
// Output: '{"name":"Miles","age":18,"city":"New York",work:"Spiderman"}

📜 Chapter 3: Why is Deserialization ?

🕸️Now Gwen have to Deserialize JSON object miles back to our JS object miles .

🕸️Deserialization is the opposite of serialization—it converts a JSON string back into a JavaScript object .

🕸️Gwen have to Deserialize Miles back for that she can use -

const user = {"name":"Miles","age":18,"city":"New York",work:"Spiderman"}

const deserializedMiles = JSON.parse(user)

We have successfully teleported Miles to other dimention

🏆 Summary: Mastering the Ninja Art of Data Handling

TechniqueFunction
JSON.stringify()Teleport Miles (Serialization)
JSON.parse()Gwen retrives miles (Deserialization)

Now, young Spiderman's , you have unlocked the Power of teleportation

Thanks to Ashutosh Kumar got a lot of inspiration from your article link for his article https://serializationdeserialization.hashnode.dev/serialization-and-deserialization-the-magic-scrolls-of-data

Special thanks to Hitesh & Piyush sir for this amazing course web cohort - Learning beyond code.