Bỏ qua đến nội dung chính
FreeOnlineTools Go
Tiếng Việt
explanation

JSON Là Gì? Giải thích Đầy đủ về JavaScript Object Notation

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

JSON là định dạng văn bản biểu diễn dữ liệu cấu trúc dùng cặp key-value và array. Nó hỗ trợ sáu kiểu dữ liệu: string, number, boolean, null, object và array. JSON là chuẩn trao đổi dữ liệu giữa web server và trình duyệt. Dùng JSON Formatter miễn phí.

Introduction

JSON (JavaScript Object Notation) là định dạng trao đổi dữ liệu text-based nhẹ, dễ đọc và viết cho con người, dễ parse và generate cho máy. Mặc dù tên, JSON language-independent —được dùng bởi Python, Java, Go và thực tế mọi ngôn ngữ lập trình hiện đại. JSON được định nghĩa bởi RFC 8259 và là định dạng dữ liệu dominant cho web API và cơ sở dữ liệu NoSQL.

Step by Step

  1. Understand JSON syntax

    JSON uses curly braces {} for objects (key-value pairs), square brackets [] for arrays (ordered lists), and colons to separate keys from values. Keys must be strings in double quotes. Values can be strings, numbers, booleans, null, objects, or arrays.

  2. Learn the six data types

    JSON supports exactly six data types: string (in double quotes), number (no distinction between int/float), boolean (true or false), null, object ({...}), and array ([...]). JSON does not support undefined, functions, dates, or NaN.

  3. Recognize JSON structure

    A JSON document is either an object or an array at the top level. Objects contain key-value pairs; arrays contain ordered values. Structures can be nested to any depth — an object value can be another object or array.

  4. Parse and generate JSON

    In JavaScript, JSON.parse(string) converts a JSON string to a JavaScript object, and JSON.stringify(object) converts a JavaScript object to a JSON string. Every modern language has equivalent functions.

Examples

A simple JSON object

Input: Person with name and age

Output: {"name": "Alice", "age": 30}

JSON with nested structure

Input: User with address

Output: {"name": "Alice", "address": {"city": "NYC", "zip": "10001"}}

JSON array

Input: List of numbers

Output: [1, 2, 3, 4, 5]

Common Problems

  • Using single quotes —JSON requires double quotes for all strings and keys. Single quotes are invalid.
  • Trailing commas —a comma after the last item in an object or array is a syntax error in JSON.
  • Comments —standard JSON does not support comments. Use JSONC or JSON5 if you need comments.
  • Unquoted keys —unlike JavaScript object literals, JSON requires all keys to be in double quotes.

Tips

  • JSON is language-independent despite its name —every modern language has JSON support.
  • Use JSON for API requests and responses —it is the de facto standard, replacing XML.
  • Validate JSON before sending it in an API request to avoid 400 errors.
  • Use our JSON Formatter to beautify, validate, and minify JSON instantly in your browser.

Related Tools

Related Guides

References