how to write in a json file with rapidjson code example

Example 1: write json file nodejs

const fs = require('fs');
const path = require('path');

let student = { 
    name: 'Mike',
    age: 23, 
    gender: 'Male',
    department: 'English',
    car: 'Honda' 
};
 
fs.writeFileSync(path.resolve(__dirname, 'student.json'), JSON.stringify(student));

Example 2: how to read and parse a json file with rapidjson

FILE *fp = fopen("input.json", "r"); // stupid windows need rb
    char buf[0XFFFF];
 
    //FileReadStream(FILE *fp, char *buffer, std::size_t bufferSize)
    rapidjson::FileReadStream input(fp, buf, sizeof(buf));
    rapidjson::Document document;
    document.ParseStream(input);
    fclose(fp);

	cout << document["hello"].GetString() << endl;