Hi, I'm making a game server and my database is in JSON format. However, I would like to know how do I check if a field exist in the .json file and add in the field if it doesn't exist?
#include "json.hpp"
std::ifstream ifff("players/" + PlayerDB::getProperName(p->rawName) + ".json");
json j;
ifff >> j;
int bac, han, fac, hai, fee, pan, nec, shi, mas, lvl, gem, mut, ban, adl;
bac = j["ClothBack"];
han = j["ClothHand"];
fac = j["ClothFace"];
hai = j["ClothHair"];
fee = j["ClothFeet"];
pan = j["ClothPants"];
nec = j["ClothNeck"];
shi = j["ClothShirt"];
mas = j["ClothMask"];
lvl = j["Level"];
gem = j["Gems"];
mut = j["isMuted"];
ban = j["isBanned"];
adl = j["adminLevel"];
ifff.close();
For example, I want to add in a new field called "SkinColor". How do I check if the field exists or not in the json file and write it in if it doesn't exist? Thanks in advance.