JSON
JSON Path Extractor / Flatten
تسطيح (Flatten) JSON متداخل إلى قائمة مسطحة "مسار: قيمة" وإعادة تجميعه إلى بنية متداخلة (Unflatten). ترميز المسار هو نفسه المستخدم في JSONPath/JSON Diff: store.book[0].price.
Deeply nested JSON is hard to compare or iterate over programmatically. Flatten unrolls such a structure into a flat list of "path: value" pairs (e.g. store.book[0].price: 12.99), and Unflatten rebuilds it.
How to use it
- Flatten: paste nested JSON and get a flat list of every leaf value with its full path.
- Unflatten: paste a list of "path: value" pairs to rebuild a nested JSON structure from it.
- The path notation matches this site's JSONPath and JSON Diff tools — items[0].name for array elements.
Common uses
- Turning a deeply nested API response into a flat list for import into a spreadsheet or analytics system.
- Building a translation dictionary or config back into nested JSON from flat keys (form.errors.email).
- Quickly finding every value on a given topic in a very large JSON document via a flat path list.
Things to keep in mind
Array index notation varies between libraries — this tool uses items[0], though some write items.0 without brackets.
Unflatten requires that paths don't conflict with each other (e.g. one and one.two at the same time) — otherwise the structure can't be unambiguously rebuilt.
مقالة عن هذه الأداة: JSON Flatten: تحويل بنية متداخلة إلى قائمة مسطحة
الأسئلة الشائعة
كيف تُمثَّل عناصر المصفوفات في المسار المسطح؟
تتحول إلى مفاتيح مرقمة داخل المسار مثل store.book[0].price، بحيث يشير الرقم بين القوسين إلى فهرس العنصر داخل المصفوفة.
هل يمكن التراجع عن التسطيح والعودة إلى البنية الأصلية؟
نعم، وضع Unflatten يعيد بناء JSON متداخل من قائمة "مسار: قيمة"، باستخدام نفس ترميز المسار المستخدم في Flatten.
هل تتم معالجة JSON على خادم خارجي؟
لا، كل من التسطيح وإعادة البناء يتمّان بالكامل داخل المتصفح عبر JavaScript دون إرسال أي بيانات لخادم.
ماذا يحدث إذا كان المفتاح الحقيقي نفسه يحتوي نقطة؟
هذه حالة غامضة: المسار user.name قد يعني كائنًا متداخلًا {"user": {"name": ...}} أو مفتاحًا مسطحًا {"user.name": ...}. صيغة الترميز بالنقاط لا تميّز بين الحالتين، لذا يُستحسن تجنّب مثل هذه المفاتيح أو معالجتها بشكل منفصل.
هل صيغة المسارات موحّدة في كل الأدوات المشابهة؟
لا. الترميز بالنقاط للكائنات (user.name) شائع في كل مكان تقريبًا، لكن ترميز فهارس المصفوفات يختلف: هنا يُستخدم items[0]، بينما تكتبه بعض المكتبات items.0 بلا أقواس.