-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsoncpp_test.cpp
64 lines (43 loc) · 1.54 KB
/
jsoncpp_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <json/writer.h>
#include <cstdlib> //Unnecessary in real version?
//#include <random> //Unnecessary in real version
#include <fstream>
#include <unistd.h> //For Sleep(). Unnecessary in real version.
//for output filename stuff
#include <iomanip>
#include <sstream>
int main(){
Json::Value data;
srand (time(NULL));
std::ofstream out_stream;
for(int year=0; year<5000; year++){
for(int month=0; month<12; month++){
data["Year"] = year;
data["Month"] = month;
//Monthly Thermal information
data["TempAir"] = rand()%100*1.0;
data["TempOrganicLayer"] = rand()%100*1.0;
data["TempMineralLayer"] = rand()%100*1.0;
data["PAR"] = rand()%100*1.0;
data["ActiveLayerDepth"] = rand()%100*1.0;
//Monthly Hydrodynamic information
data["Precipitation"] = rand()%100*1.0;
data["WaterTable"] = rand()%100*1.0;
data["VWCOrganicLayer"] = rand()%100*1.0;
data["VWCMineralLayer"] = rand()%100*1.0;
data["Evapotranspiration"] = rand()%100*1.0;
//std::cout << data << std::endl;
std::cout << "year: "<<year<<", month: "<<month<<std::endl;
std::stringstream filename;
filename.fill('0');
filename << std::setw(4) << year << "_" << std::setw(2) << month << ".json";
out_stream.open(filename.str().c_str(), std::ofstream::out);
out_stream << data << std::endl;
out_stream.close();
sleep(1);
}
}
std::cout<<std::endl;
return 0;
}