Data Formats (JSON, YAML, TOML, XML, CSV) Module 10
Across formats: time, conversion, streaming, evolution, binary interview questions
Interview questions on “Across formats: time, conversion, streaming, evolution, binary”.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
How should an API send a timestamp in JSON, and why?
-
Fresher to mid
Why can a conversion between two formats lose data even when both converters work?
Answered in the lesson Converting between formats without losing data
-
Fresher to mid
What is the difference between parsing a document whole and streaming it?
Answered in the lesson Streaming large JSON, XML and CSV files
-
Fresher to mid
What do backward and forward compatibility mean for a schema change?
Answered in the lesson Schema evolution: change formats safely
-
Fresher to mid
When does a binary format beat JSON?
Answered in the lesson Beyond text: CBOR, MessagePack, Protobuf, Parquet
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
A partner's JSON feed sends order times without an offset. Your daily totals look right, but orders placed late in the evening sometimes land on the next day. What happened, and how do you fix the feed and the rows already stored?
- What it tests
- Recognising a lost offset from its symptoms, finding the zone the sender meant, repairing stored instants without guessing, and making the contract refuse times without an offset.
- First step
- Compare a few stored orders with the partner's own records. If the gap is always the partner's offset, such as 5 hours 30 minutes, the feed's local times were read as UTC. Then get the partner to state in writing which zone their clock uses.
- Follow-ups
-
- How do you repair the rows already stored?
- How do you stop it from happening again?
- What changes if the partner's zone has daylight saving?
From the lesson Dates and times across data formats
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Design how a booking service stores and returns appointment times for clinics in India, the United Kingdom and the United States, including bookings made months ahead. What do you store, and what does the API return?
- What it tests
- Separating instants from booked local times, choosing zone names over offsets for future events, and handling gaps, overlaps and rule changes in the API.
- First step
- Split the times into two kinds. Moments that have happened, such as when a booking was made, are instants. The appointment itself is a local time that a patient expects at one clinic, so store it as the local time plus the clinic's IANA zone, not as an instant.
- Follow-ups
-
- What does the API return to a phone in another zone?
- What happens to a booking at 01:30 on the night the clocks change?
- How do you handle a government changing its zone's rules?
From the lesson Dates and times across data formats
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
An XML-to-JSON gateway has run for months. Today a consumer crashed on an order whose item field arrived as an object instead of an array. Why only today, and how do you make the mapping safe for every consumer?
- What it tests
- Recognising the array-of-one trap, fixing the mapping from the schema rather than from samples, and protecting consumers while the gateway changes.
- First step
- Look at the order that crashed: it has exactly one item element, and every earlier order had two or more. The convention turns a repeated name into an array and a single one into an object, so the field's shape followed the data, not the schema.
- Follow-ups
-
- Where does the list of always-array names come from?
- How do you change the gateway without breaking consumers that already handle both shapes?
- What else does this kind of mapping lose?
From the lesson Converting between formats without losing data
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
You must move 2,000 service configuration files from YAML to JSON without changing what any service reads. How do you convert them, and how do you prove that nothing changed?
- What it tests
- Knowing what YAML holds that JSON does not, choosing the loader's schema, and proving equivalence with a loss report and a round trip before any service switches.
- First step
- Scan all 2,000 files for what JSON cannot hold: .inf and .nan, keys that are not strings, anchors and merge keys, custom tags, several documents in one file, and plain scalars that a YAML 1.1 loader types differently. Each kind of finding needs a rule before any file is converted.
- Follow-ups
-
- Which YAML loader do you convert with?
- How do you prove that each service reads the same values?
- What happens to the comments?
From the lesson Converting between formats without losing data
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A nightly job that totals sales from a 6 GB JSON export is killed for running out of memory. The export is one big array of orders. What do you change, and how do you show that the job now runs within a fixed memory budget?
- What it tests
- Estimating the memory of a whole-document parse, choosing a streaming reader or format, and proving a flat memory profile with a measurement rather than a hope.
- First step
- Measure the parse on a sample: the lesson's run took about six times the file's size for a JSON array, so 6 GB would need roughly 36 GB. That rules out any whole-document parser, so the job must read one order at a time.
- Follow-ups
-
- Can you change the export format, and to what?
- How do you measure the new peak, and on what input?
- What if the job also needs the top 100 orders by amount?
From the lesson Streaming large JSON, XML and CSV files
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A streamed import of product prices shows a garbled rupee sign in about one row in four thousand, always a different row, and the source file is fine. What is the bug, and how do you fix it and prove the fix?
- What it tests
- Recognising a chunk-boundary decoding bug from its symptoms, fixing it with one incremental decoder, and testing every cut position instead of one sample file.
- First step
- The rows change between runs and the file is fine, so the damage happens while reading. A multi-byte character cut by a chunk boundary fits: a decoder made per chunk turns its pieces into replacement characters without an error. Check how the import decodes its chunks.
- Follow-ups
-
- Why roughly one row in four thousand?
- How would you make the import refuse such damage instead of hiding it?
- How do you test the fix?
From the lesson Streaming large JSON, XML and CSV files
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
An order event is read by 12 services owned by different teams. You must add a required currency field without stopping any of them, and some orders sit in queues for up to three days. Plan the rollout.
- What it tests
- Splitting a change that is compatible in one direction into steps that are compatible in both, ordering consumers and producers, and knowing when old data is truly gone.
- First step
- Classify the change first: a new required field is forward compatible only, because new readers would refuse old orders. So it cannot ship as one step. Make it optional with a documented default for every consumer before any producer depends on it.
- Follow-ups
-
- How do you know every consumer has upgraded?
- When exactly may the field become required?
- What do you do about orders stored before the change?
From the lesson Schema evolution: change formats safely
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your team's JSON message schemas all use additionalProperties false, to catch typos. What does that cost when the format evolves, and how would you change it without breaking current clients?
- What it tests
- Seeing that closed schemas turn additions into breaks, knowing the must-ignore policy, and opening a schema in a compatible order while keeping typo detection somewhere else.
- First step
- Work out what an addition does today: with additionalProperties false, every new member is refused by every reader on the previous version, so each addition needs every reader upgraded first. Opening a schema is itself a change to classify before you make it.
- Follow-ups
-
- In which order do you open the schemas of readers and writers?
- How do you still catch a misspelt member?
- Are there messages where a closed schema is right?
From the lesson Schema evolution: change formats safely
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A mobile app uploads telemetry as JSON batches of about 40 KB, compressed with gzip, over slow connections. The team proposes Protocol Buffers to cut data costs. How do you decide, and what numbers do you need first?
- What it tests
- Measuring before switching, comparing raw and compressed sizes on real batches, and weighing schema management, debugging and parsing cost against the bytes saved.
- First step
- Take a few hundred real batches and encode each as compact JSON and as Protocol Buffers, then compress both with the same gzip setting the app uses. The traffic is already compressed, so the compressed sizes, not the raw ones, decide the data saving.
- Follow-ups
-
- The compressed saving turns out to be 6 %. Is it still worth it?
- How do the app and the server keep the schema in step?
- What do you lose when a support engineer debugs a batch?
From the lesson Beyond text: CBOR, MessagePack, Protobuf, Parquet
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
An analytics team stores a day's events as JSON Lines, about 200 GB a day with 60 fields, and most queries use 3 of them. Recommend a storage format and layout, and explain the trade-offs.
- What it tests
- Matching row and columnar formats to write and read patterns, sizing the saving from columns read, and planning row groups, partitions and schema changes.
- First step
- Separate the write path from the read path. Events arrive one at a time, which suits a row format; queries read 3 of 60 columns over many rows, which suits a columnar file. So keep a row format for arrival and convert finished batches to a columnar format for querying.
- Follow-ups
-
- How large should files and row groups be?
- How do you partition the data?
- What happens when a field is added or changes type?
From the lesson Beyond text: CBOR, MessagePack, Protobuf, Parquet
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
All Data Formats (JSON, YAML, TOML, XML, CSV) interview questions · The Data Formats (JSON, YAML, TOML, XML, CSV) track