'use strict';

const person = {
  name: 'John Doe',
  age: 30,
  profession: 'Web Developer',
};

// Convert JavaScript object to JSON string
const jsonString = JSON.stringify(person);
console.log(jsonString);
// => {"name":"John Doe","age":30,"profession":"Web Developer"}

try {
  // Convert JSON string back to JavaScript object
  const parsedPerson = JSON.parse(jsonString);
  console.log(parsedPerson.name); // => John Doe
  console.log(parsedPerson.age); // => 30
} catch (error) {
  console.error('Invalid JSON:', error);
}
