i have a NodeJs applet that I want to save the Users Array (Contains Objects) to a File, I am doing this with:
const fs = require('fs');
const util = require('util');
fs.writeFileSync('data/inventur_users.json', util.inspect(users), 'utf-8');
The Output in the File inventur_Users.json is:
[ BU4AFLx3cUYqdjvYPci7: { id: '5LkOWtVFcqz29UpsAAAC',
name: '[email protected]',
rechte: 'vollzugriff',
client_ID: 'BU4AFLx3cUYqdjvYPci7' } ]
Now I am Reading the file back in with this code:
filedata = fs.readFileSync('data/inventur_users.json', 'utf-8');
My Problem is that i only get a String and I don't know how to convert the String back to an Array that contains Objects.
Thanks in advance, Patrick