Easy👤 0-2 years👤 3-5 years 1 min read

Serialization vs Deserialization — Interview Questions

Asked inInfosysTCSAmazonDeloitte
#json#serialization#deserialization#stringify#parse
Report issue

⚡ Short Answer

Serialization turns an in-memory object into a JSON string (JSON.stringify, json.dumps) for storage or transmission; deserialization does the reverse, turning a JSON string back into objects (JSON.parse, json.loads). Serialize on the way out, deserialize on the way in.

Coffee Chat Question

Concept Made Simple

What is the difference between serialization and deserialization?

🧠Mind Map Answer

Remember It Faster

Serializeobject → JSON string (stringify/dumps)
DeserializeJSON string → object (parse/loads)
Whenserialize to send/store, deserialize to read
Watchdates, undefined, functions drop/convert

⌨️Hands-on Keyboard

Learn by Doing

javascript
const obj = { id: 1, when: new Date("2026-08-01"), fn: () => 1 };

const text = JSON.stringify(obj);   // serialize
console.log(text);
// {"id":1,"when":"2026-08-01T00:00:00.000Z"}  (fn is dropped!)

const back = JSON.parse(text);      // deserialize
console.log(typeof back.when);      // "string" — not a Date

🔥What If?

Think Beyond the Expected

What happens to a Date, a function, and undefined during JSON.stringify?

A Date becomes its ISO string (and won't turn back into a Date on parse), while functions, undefined values, and symbols are omitted from objects (and become null inside arrays). That asymmetry is why round-tripping isn't lossless — you often need a reviver on parse or a toJSON/DTO on serialize.

😂Real World

The 'my date is now a string' bug comes straight from this: you stringify an object with a Date, send it, parse it, and the field is a string. Teams add reviver functions or map to DTOs to restore types after deserialization.

🎯Interviewer's Expectation

Keywords they're listening for:

serialize = object→stringdeserialize = string→objectstringify/parse, dumps/loadslossy for date/undefined/functionreviver/replacer

⚠️Common Mistakes

  • Expecting a lossless round-trip for dates
  • Forgetting functions/undefined are dropped
  • Confusing which direction is which

Best Practices

  • Use a reviver/DTO to restore types
  • Send dates as ISO strings deliberately
  • Keep serializable objects plain (no functions)

🔁Follow-up Questions

  • 1What do the replacer and reviver arguments do?
  • 2How do you preserve types across a round-trip?
  • 3How do Jackson/Gson map JSON to typed classes?

🧩Related Technologies

JSON.stringifyreviver/replacerJacksonDTO

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Serialization (JSON)
Interview question: "What is the difference between serialization and deserialization?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions