EasyπŸ‘€ 0-2 yearsπŸ‘€ 3-5 years 4 min read Updated Aug 24, 2026

What is JSON? Interview Questions

Reviewed by Gurusankar M. Β· Updated Aug 24, 2026

Asked inInfosysTCSAccentureCognizant
#json#javascript object notation#data format#basics#data interchange
Report issue

⚑ Short Answer

JSON (JavaScript Object Notation) is a lightweight, text-based, language-independent format for storing and exchanging data as key/value pairs and ordered lists. It grew out of JavaScript object syntax but is now used by nearly every language and is the default payload format for REST APIs.

β˜•Coffee Chat Question

Concept Made Simple

β€œWhat is JSON?”

🧠Mind Map Answer

Remember It Faster

JSON is just text that describes data in a shape almost every language understands. Machines exchange it; humans can read it.

Stands for→JavaScript Object Notation
Form→Text — objects `{}` and arrays `[]`
Used for→APIs, config, logs, messaging
Language→Independent (not just JavaScript)

JSON looks like a JavaScript object literal because that's where it came from, but the grammar is stricter β€” and code that's valid as a JS literal is often invalid JSON. A JavaScript object is a live, in-memory value with any key type and any value, including functions and Dates; JSON is a text format with only six value types (string, number, boolean, null, object, array), no comments, no trailing commas, and keys that must be double-quoted strings.

json
// Valid as a JS object literal β€” INVALID as JSON:
{ name: 'Guru', role: "Engineer", /* comment */ tags: ['java', 'aws',], }
// ^ unquoted key   ^ single quotes   ^ comment    ^ trailing comma β€” all illegal in JSON

// The strict JSON equivalent:
{ "name": "Guru", "role": "Engineer", "tags": ["java", "aws"] }

Two lesser-known gotchas that only show up once JSON meets real production data. Duplicate keys are legal JSON β€” the spec doesn't forbid { "role": "admin", "role": "user" } β€” but it also doesn't say what a parser should do with it, so behavior is implementation-defined; JavaScript's JSON.parse() silently keeps the last value and drops the rest, other languages' parsers can differ, and no error is ever raised either way. Large integers lose precision when parsed: JSON numbers have no size limit, but JSON.parse() decodes every number as a JavaScript double, which can only represent integers exactly up to 2^53 β€” a 64-bit id like a Snowflake ID or a Twitter/Discord post id silently rounds to the nearest representable double once parsed. This is exactly why large-ID APIs return those ids as strings, not numbers, in their JSON responses β€” it isn't a style choice, it's a precision workaround.

The Content-Type: application/json header is a contract, not a formality. It tells the receiving side how to interpret the bytes β€” a server that returns JSON with text/plain (or omits the header) invites clients to guess, which is exactly the kind of ambiguity structured content types exist to remove; most HTTP frameworks and fetch/axios-style clients key their automatic parsing off this exact header. The JSON spec (RFC 8259) additionally mandates UTF-8 as the encoding for JSON exchanged over a network β€” UTF-16/UTF-32 are permitted for JSON as a general text format but not for interchange, which is why a JSON parser never needs a byte-order mark or an encoding declaration the way XML does.

JSONP is worth recognizing even though it's obsolete. Before CORS existed (pre-2010s), browsers' same-origin policy blocked a page from fetching JSON from a different domain via XMLHttpRequest β€” but <script src="..."> tags were exempt from that restriction. JSONP exploited this: a server would wrap its JSON response in a function call (callback({...})) and the client would load it as a <script>, letting a pre-registered JavaScript function receive the data as a plain argument. It worked, but it meant trusting a third-party server to inject and execute arbitrary code in your page β€” a real security liability. CORS made this workaround unnecessary, and JSONP now mostly shows up in interviews as a "why was this ever a good idea" history question, not a technique anyone should reach for today. Modern APIs handle cross-origin access with explicit Access-Control-Allow-Origin response headers instead, giving the server (not an implicit script-tag loophole) control over exactly which origins may read its JSON.

⌨️Hands-on Keyboard

Learn by Doing

json
{
  "name": "Guru",
  "age": 30,
  "isEngineer": true,
  "skills": ["Java", "AWS"],
  "address": { "city": "Chennai" }
}

πŸ”₯What If?

Think Beyond the Expected

Is JSON the same thing as a JavaScript object?

No. JSON is a text FORMAT inspired by JavaScript object literals, but it's stricter β€” keys must be double-quoted strings, no comments, no trailing commas, no functions or dates. A JavaScript object lives in memory; JSON is a string you parse into (or serialize from) such objects.

πŸ˜‚Real World

Almost every API response you've ever seen is JSON β€” the frontend fetches it, parses it, and renders the UI. It's also everywhere in config files (package.json, tsconfig.json), log lines, and message queues. One practical gotcha that trips people up in production: JSON.stringify() silently drops object properties whose value is undefined or a function, and converts a Date into an ISO-8601 string β€” so round-tripping through JSON.parse(JSON.stringify(obj)) doesn't always give you back the exact object you started with.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ text-based data formatβœ“ key/value + arraysβœ“ language-independentβœ“ default for REST APIsβœ“ human-readable

⚠️Common Mistakes

  • βœ—Calling JSON a programming language
  • βœ—Assuming it's JavaScript-only
  • βœ—Confusing the in-memory object with the JSON string

βœ…Best Practices

  • βœ“Use JSON for interchange, not as an in-memory type
  • βœ“Keep keys consistent (camelCase or snake_case)
  • βœ“Validate JSON at trust boundaries

πŸ”Follow-up Questions

  • 1How is JSON different from a JavaScript object?
  • 2What data types does JSON support?
  • 3Why did JSON become more popular than XML?

🧩Related Technologies

RESTJavaScriptYAMLXML

πŸ“šReferences

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: Basics (JSON)
Interview question: "What is JSON?"

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.

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