كتابة Json Development Tutorials, Guides & Insights
Unlock 1+ expert-curated كتابة json tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your كتابة json skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Tutorial
javascript
التعامل مع JSON في JavaScript: قراءة البيانات وكتابتها
في JavaScript (في بيئات Node.js)، يمكنك أيضًا كتابة بيانات JSON إلى ملف. أولاً، تحتاج إلى تحويل الكائن إلى JSON باستخدام JSON.stringify()، ثم استخدام الوحدة fs لكتابة البيانات إلى ملف.
const fs = require('fs');
const person = {
name: "أحمد",
age: 30,
isMarried: false,
children: ["سارة", "علي"]
};
const jsonString = JSON.stringify(person, null, 2);
fs.writeFile('person.json', jsonString, (err) => {
if (err) {
console.error('حدث خطأ أثناء الكتابة إلى الملف', err);
} else {
console.log('تم كتابة الملف بنجاح!');
}
});Sep 26, 2024
Read More