LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the key differences between XML and JSON, and which is preferred for web APIs?

JSON is compact and maps straight onto JavaScript data, while XML is more verbose but supports attributes, comments, and richer schema validation — and for web APIs, JSON usually wins.

The same data shows the contrast. In XML a list of relatives needs a repeated tag for each item:

<relatives>
  <relative>Grandpa</relative>
  <relative>Marge</relative>
</relatives>

In JSON it's just an array, and converting it into program data is direct:

{ "relatives": ["Grandpa", "Marge"] }
Feature JSON XML
Syntax Braces {} / brackets [] Start/end tags
Verbosity Compact Verbose (the slide calls it a "space waster")
Mapping to program data Direct (object, array) Extra work to turn tags into objects
JavaScript Native (JSON.parse) Needs parsing
Comments Not allowed Allowed
Attributes No Yes
Schema validation JSON Schema XSD, DTD

For web APIs JSON is typically preferred — smaller payloads and effortless JavaScript integration. XML still appears in enterprise systems, document formats, and standards (like SOAP) where its attributes and strict schemas earn their keep.

From Quiz: WEBT / External Webservices | Updated: Jul 14, 2026