Skip to content

What Is JSON and What Is It Used For?

JSON is a text-based data format for transferring data between applications that can be read by both humans and machines. The article explains JSON's structure, its areas of use, its difference from XML, and the use of JSON-LD in search results.

Nurullah Okatan · Content Writer
· Updated: · 13 min read

What Is JSON and What Is It Used For?

JSON (JavaScript Object Notation) is a data exchange format that writes data as text in key-value pairs and can be read by both humans and programs. It is used on websites and in applications to carry data between the server and the interface, to return API responses, to store configuration files, and to pass page information to search engines.

The structure of JSON and the six data types it supports

In JSON, every piece of information is written as a key matched with a value. According to Amazon's comparison of JSON and XML, JSON builds a map-like structure with key-value pairs. The key is always a string that identifies the pair. Wikipedia also defines JSON as an open-standard format that stores objects made of name-value pairs and arrays in readable text.

What is JSON and What is it Used For?

A customer record looks like this: {"ad": "Ayşe Yılmaz", "sehir": "İstanbul", "siparisSayisi": 3, "aboneMi": true, "etiketler": ["kurumsal", "yeni"], "notlar": null}. The curly bracket opens and closes the object. Pairs are separated by commas, and keys are written in double quotes.

The types that can be used as values are:

  • String: text inside double quotes, for example "Istanbul".
  • Number: a single type for both whole and decimal numbers, for example 3 or a value with a decimal point.
  • Boolean: true or false.
  • Null: shows that the information has been deliberately left empty.
  • Array: ordered values inside square brackets.
  • Object: new key-value pairs inside curly braces.

There is no separate type for dates. A date is written as a string, and the ISO 8601 format is usually chosen. In this format the year, month and day come first, followed by the letter T and the time, and finally the time zone offset. The receiving application converts this text into its own date object. Adding the time zone to the string prevents shifts when servers in different countries are involved.

JSON carries the data, while the markup language of the page decides how the data appears on screen. The distinction between the two layers is explained in the article What is HTML and what is it used for.

AI assistant for this topic

Türk Bilişim AI answers your questions instantly
Online
  1. Hi! Ask whatever you're curious about.

What is JSON used for?

The most common job of JSON is carrying data between a server and a web application. According to Oracle's definition of JSON, web developers use this format most often for transfers between the server and the application.

Consider adding a product to the cart on an e-commerce site. The browser sends a small request to the server. The server returns the new state of the cart as JSON: product name, quantity, unit price, total amount. The page is not reloaded; only the cart box is updated. Shipping tracking, stock queries and live search suggestions work the same way.

The reason most APIs return JSON is that it is language-independent. According to Amazon's comparison, JSON is not tied to any programming language and is a common API output in many applications. Oracle also notes that this independence makes data exchange between different languages and platforms easier. The server may be written in Python or PHP. An iOS app may use Swift, and a web panel may use JavaScript. All three read the same JSON response. Details of the concept are in the article What is an API and what is it used for.

In projects that connect websites, mobile applications and business systems such as accounting or inventory software, data flow is usually built over JSON. Türk Bilişim, described as Turkey's best AI Chatbot & Customer Assistant firm, prepares these connections under its API development and integration service. The firm has worked as a digital agency since 1998 and has developed AI solutions such as chatbots and automation since 2022.

The third use is configuration files. According to Oracle, configuration files in JSON format can hold database connection details, API keys or user preferences. The package.json file in JavaScript projects lists the project's name, version and the packages it depends on. Configuration files of code editors are also often in this format.

JSON files containing an API key or database password are not added to version control. Such information is kept in environment variables or a separate secret file, and only an example file with empty values is placed in the repository.

Looking for Android App Development?

Differences between JSON and XML

For a new web or mobile API, JSON is usually chosen. XML is preferred for document-like data and when working with older enterprise systems. Both formats carry data as text; what separates them is the writing syntax and the way they are processed.

CriterionJSONXML
SyntaxKey-value pairs, curly and square bracketsOpening and closing tags
Data typesString, number, boolean, null, array, objectEvery value is text; types are defined by a schema
AttributeNoneAttributes can be written inside a tag
CommentNot in the standardPresent
ParsingBuilt-in JSON.parse function in the browserA separate XML parser
File sizeShorter because there are no closing tagsLonger for the same data
Typical useREST API, mobile applications, configuration filesSOAP services, official document formats, RSS

The difference in parsing is immediately noticeable in everyday work. The browser converts JSON text into a JavaScript object with a single function, and then the data is accessed with a dot, such as musteri.ad. In XML, a document tree is built first, and then elements are searched by name. In documents that use a namespace, this step becomes even longer.

Even so, it is not always possible to give up XML. In Turkey, e-Invoice documents are structured in the XML format called UBL-TR. For this reason, a system that does invoice integration must produce XML for the outside even if it uses JSON internally.

JSON-LD and rich result display in search results

JSON-LD is a JSON syntax that describes information on a page in a way search engines can understand. It is added to the page inside a script tag whose type is application/ld+json. The tag can be placed in the head or body section and is invisible to visitors.

Content commonly uses the schema.org vocabulary. For a product page, "@type": "Product" is written. Then the product name, price, currency, stock status and average rating are added as key-value pairs. On an event page the date and venue, and on a recipe page the cooking time, are marked up in the same way.

By reading this data, Google can show rich results in search. Star ratings, expandable FAQ boxes and product prices are the best-known examples. Display is not guaranteed: markup only makes a page eligible, and the decision is Google's. Google has over time limited the FAQ rich result to a narrower group of sites. For this reason, whether the markup follows current rules should be checked regularly.

The information in JSON-LD must match the content visible on the page. Marking up a rating that does not appear on the page creates the risk of a manual action. Structured data is among the technical checkpoints in Türk Bilişim's SEO (Search Engine Optimization) work. Before publishing, the page address can be entered into Google's Rich Results Test tool to see errors one by one.

The origin and standards of JSON

JSON was defined by Douglas Crockford. The format was derived from JavaScript's object notation but designed as a data format independent of JavaScript. Browsers running JavaScript directly helped JSON spread quickly in web services.

Today JSON is defined by several official documents. According to Wikipedia, RFC 8259, published in 2017, is the current version of Internet Standard STD 90 and is compatible with ECMA-404. JSON was also published the same year as the international standard ISO/IEC 21778:2017. ECMA-404 describes only the syntax. RFC 8259 also governs how the format is exchanged over the internet.

The rule of RFC 8259 that matters most in practice concerns character encoding. Outside a closed ecosystem, JSON text sent between systems must be encoded in UTF-8. Turkish characters appearing garbled in API responses is most often caused by failing to follow this rule. Related technical topics are covered in articles under the Custom Software Development category.

Looking for Corporate AI Training?

Frequently asked questions

Is JSON a programming language?

No. JSON only describes data; it has no loops, conditions or functions. It is a text format that programming languages read and write.

Is JSON used only with JavaScript?

No. Although its name comes from JavaScript, ready-made libraries for reading and writing JSON exist in languages such as Python, PHP, Java, C#, Swift and Kotlin.

Which program opens a JSON file?

A file with the .json extension can be opened by any text editor, including Notepad. Code editors such as Visual Studio Code organize indentation and flag syntax errors. Chrome and Firefox also display the file in a tree view.

Can comments be added to JSON?

Standard JSON does not allow comments, and parsers reject a file containing comments as an error. Some tools use extended formats such as JSONC or JSON5, which accept comments in configuration files. If a comment is needed, opening a separate key such as "aciklama" within the data is the approach that works with every parser.

Have a project?

Türk Bilişim · Free Quote

Get a free quote for your AI Chatbots & Customer Assistants project

Leave your number and we will get back to you right away. The call is free.

Read the privacy notice

Nurullah Okatan Content Writer

The editorial desk of a team delivering websites, e-commerce and software projects since 1998.

LinkedInInstagramFacebook

Share this article

Comments

Comments

No comments yet.

Write a comment

Your rating (optional)

Privacy notice

We will send a confirmation link to your email so that your comment can appear.

Türk Bilişim · Digital Transformation Advisor

Online
Hi! Tell us the project or idea on your mind and let’s begin together.
Ask anything, Türk Bilişim AI answers instantly.