If I serialize a linked list to JSON and store it in a text file
const list = new SinglyLinkedList();
list.push('Hello');
list.push('World');
list.push('!');
list.print();
fs.writeFile('./test.txt', JSON.stringify(list), err => {
if (err) {
console.log(err);
return;
}
})
I can read the file and de-serialize the data to get back the linked list but what if I want to add a new element in the linked list. Serialization only saves the obj state.
Is there any way by which I can add a new item to this list and serialize it again ?