10_deserialize.js 518 B

12345678910111213141516171819202122232425262728
  1. let persons = [
  2. {
  3. name: 'Sergey',
  4. surname: 'Honcharenko',
  5. age: 28,
  6. isMarried: false,
  7. },
  8. {
  9. name: 'Andrew',
  10. surname: 'Klymchuk',
  11. middleName: 'Anatoliyovych',
  12. haveAJob: true,
  13. },
  14. {
  15. name: 'Alexander',
  16. surname: 'Slobodian',
  17. sex: 'male',
  18. hasAPet: false,
  19. }
  20. ]
  21. let parsedPerson = JSON.parse('{"name":"Elena","surname":"Mospanyuk","education":true,"height":170}');
  22. console.log(persons.concat(parsedPerson));
  23. // или
  24. console.log(Object.assign(persons, parsedPerson));