EasyExperience level: 0-2 years · 3-5 years1 min read

Serialization vs Deserialization — Interview Questions

Reviewed by Gurusankar M.

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.

On this page

Concept Made Simple

Coffee Chat Question

“What is the difference between serialization and deserialization?”

Remember It Faster

Mind Map Answer

Serialize
object → JSON string (stringify/dumps)
Deserialize
JSON string → object (parse/loads)
When
serialize to send/store, deserialize to read
Watch
dates, undefined, functions drop/convert

Learn by Doing

Hands-on Keyboard

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

Think Beyond the Expected

What If?

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→string
  • deserialize = string→object
  • stringify/parse, dumps/loads
  • lossy for date/undefined/function
  • reviver/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

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

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?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.