Essential cookies keep authentication working. With your permission, we also use analytics cookies to understand and improve the product. Read our Privacy Policy

DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPricingBlog
ProLogin
Home/Questions/General/Other/What is Multiline option in JSON?

What is Multiline option in JSON?

General/Othereasy2 min read

Reviewed by Aditya Kumar · Last reviewed 2026-08-08

The multiline option in JSON parsing, when set to true , instructs the parser to treat an entire file as a single, potentially multi line JSON object or an array of JSON objects. This allows a single…

🤖 Analyze Your Answer
Frequency
Low
Asked at 1 company
Category
243
questions in General/Other
Difficulty Split
151E|43M|49H
in this category
Total Bank
1,863
across 7 categories
Asked at these companies
LTIMindtree
Key Concepts Tested
spark

Why This Question Matters

This easy-level General/Other question appears frequently in data engineering interviews at companies like LTIMindtree. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (spark) will help you answer variations of this question confidently.

How to Approach This

Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example. The expert answer includes a code example that demonstrates the implementation pattern.

Expert Answer
319 wordsIncludes code

The multiline option in JSON parsing, when set to true, instructs the parser to treat an entire file as a single, potentially multi-line JSON object or an array of JSON objects. This allows a single JSON record to span across multiple lines, including pretty-printed formats with indentation and line breaks.

By default, most big data processing frameworks (like Apache Spark) assume multiline=false, expecting each line in the file to represent a complete and independent JSON object. This format is known as JSON Lines (or NDJSON - Newline Delimited JSON). NDJSON is highly efficient for streaming and parallel processing because each line can be read and processed independently without needing to read the entire file.

The multiline=true option is primarily used when dealing with conventionally pretty-printed JSON files, such as those often returned by REST APIs or stored for human readability. These files typically contain a single large JSON object or an array of objects spanning many lines, often with formatting like indentation.

In PySpark, you would enable this option when reading a JSON file:

df = spark.read.option("multiline", "true").json("path/to/data.json")

The key trade-offs involve performance and memory. When multiline=true, the parser must read the entire file into memory (or a large buffer) to correctly identify and parse the single JSON object or array. This can be significantly slower and more memory-intensive, especially for very large files, as it prevents distributed processing where different parts of the file can be processed in parallel by different tasks. If the file contains a mix of single-line and multi-line objects, parsing can fail or produce unexpected results. For large-scale data ingestion and processing, NDJSON is almost always preferred due to its streamability, fault tolerance, and parallel processing capabilities.

In the interview, also mention that while multiline=true is convenient for API outputs, it's generally an anti-pattern for large-scale data lakes and warehouses, where NDJSON or more structured formats like Parquet or ORC are preferred.

⚡
Pro Tip

Red Flag: Multiline for large files. Pro-Move: 'We normalize to NDJSON in ingestion; multiline only for API response parsing.'

Want all answers as a PDF for offline study?
Seven focused volumes with 750+ in-depth answers — Answer Vault →

Related General/Other Questions

hardHave you worked on Data Warehousing projects?FreemediumHow would you read data from a web API? What steps would you follow after reading the data?FreehardRetrieve the most recent sale_timestamp for each product (Latest Transaction).FreehardWhat is the difference between OLTP and OLAP?FreemediumWhat is the difference between SQL and NoSQL databases?Free

Level up your prep

Recommended
Educative
Educative Unlimited

800+ hands-on courses — Grokking System Design, Coding Patterns, and AI mock interviews for your DE loop.

Start learning →

Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.

According to DataEngPrep.tech, this is one of the most frequently asked General/Other interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.

← Back to all questionsMore General/Other questions →
Categories
All QuestionsSQLSpark / Big DataPython / CodingSystem DesignCloud / ToolsBehavioral
By Company
AmazonGoogleDatabricksSnowflakeAWSAzureMicrosoftNetflixUberTCS
Interview Guides
All GuidesTop SQL QuestionsTop Spark QuestionsPySpark QuestionsTop Python QuestionsTop System DesignKafka QuestionsAirflow QuestionsSQL Window FunctionsETL QuestionsData Modeling
Products
AI Interview CoachAnswer AnalyzerSQL PlaygroundResume AnalyzerAnswer Vault PDFsPricing
Company
About & Editorial PolicyContact UsAI DisclosureDisclaimerTerms of ServicePrivacy Policy
© 2026 DataEngPrep.tech. All rights reserved.
AboutBlogContactDisclaimer