У меня есть файл вроде этого:
[data.json]
{
"electron": {
"pos": [0,0,0],
"vel": [0,0,0]
},
"proton": {
"pos": [1,0,0],
"vel": [0,0.1,0]
},
"proton": {
"pos": [-1,0,0],
"vel": [0,-0.1,-0.1]
}
}
Как создать вектор частиц при разборе этого файла. Насколько я понимаю, мне нужно прочитать файл с помощью boost и прочитать строки (строки) в вектор, а затем проанализировать содержимое вектора.
Классная частица выглядит примерно так:
class Particle
{
private:
particle_type mtype; // particle_type is an enum
vector<double> mPos;
vector<double> mVel;
};
Другие методы для get/set были опущены в классе.
В принципе, я хотел бы помочь создать vector<Particle>
с правильными данными о местоположении и скорости, а также данные частиц_частица, обработанные в нем. Спасибо заранее.
Код в основном:
int main(){
boost::property_tree::ptree pt;
boost::property_tree::read_json("data.json", pt);
}