How does JSON compare to YAML in terms of readability and ease of use for saving object data across different languages?

JSON is generally considered more readable and easier to use for saving object data across different languages compared to YAML. JSON has a simpler syntax and is widely supported in various programming languages. On the other hand, YAML can be more human-readable due to its indentation-based structure, but it can also be more complex and less consistent across different languages.

// Example of saving object data in JSON format
$data = [
    'name' => 'John Doe',
    'age' => 30,
    'email' => 'johndoe@example.com'
];

$jsonData = json_encode($data);

file_put_contents('data.json', $jsonData);