فهم JSON: دليل المبتدئين للتنسيق والتحقق
Quick Answer
JSON هو تنسيق بيانات نصي يستخدم أزواج المفتاح والقيمة والمصفوفات. يدعم السلاسل والأرقام والقيم المنطقية وnull والكائنات والمصفوفات. استخدم أداة تنسيق JSON المجانية لتجميل والتحقق وتصغير بيانات JSON — تتم جميع المعالجة في متصفحك.
Introduction
JSON (JavaScript Object Notation) هو تنسيق تبادل بيانات خفيف الوزن يسهل على البشر قراءته وكتابته، ويسهل على الآلات تحليله وتوليده. وهو تنسيق البيانات الأكثر شيوعاً المستخدم للتواصل بين خوادم الويب والمتصفحات، وقد حل إلى حد كبير محل XML في واجهات برمجة التطبيقات الحديثة.
Step by Step
-
Understand JSON syntax
JSON uses curly braces {} for objects, square brackets [] for arrays, and key-value pairs separated by colons. Keys must be strings in double quotes. Values can be strings, numbers, booleans, null, objects, or arrays.
-
Format your JSON
Paste your JSON data into the JSON Formatter tool. It will automatically beautify the JSON with proper indentation and line breaks, making it easy to read.
-
Validate the structure
The formatter checks your JSON for syntax errors. If valid, it displays the formatted output. If invalid, it shows an error message indicating the problem.
-
Copy or use the result
Copy the formatted JSON to your clipboard for use in your code, documentation, or debugging.
Examples
Simple object
Input: {"name":"Alice","age":30}
Output: {
"name": "Alice",
"age": 30
}
Array of objects
Input: [{"id":1},{"id":2}]
Output: [
{ "id": 1 },
{ "id": 2 }
]
Nested structure
Input: {"user":{"name":"Bob","tags":["admin","user"]}}
Output: {
"user": {
"name": "Bob",
"tags": ["admin", "user"]
}
}
Common Problems
- Using single quotes for strings —JSON requires double quotes for strings and keys.
- Trailing commas —JSON does not allow a comma after the last item in an object or array.
- Comments —JSON does not support comments (// or /* */). Use JSONC or JSON5 if you need comments.
- Unquoted keys —all keys must be in double quotes, unlike JavaScript object literals.
Tips
- Use a JSON formatter to catch syntax errors before sending data to an API.
- Minified JSON saves bandwidth —use minification in production, formatting in development.
- JSON does not support undefined, functions, or dates as values —use null or ISO 8601 strings.
- Use JSON.parse() in JavaScript to convert JSON strings to objects, and JSON.stringify() to convert objects to JSON.