Skip to content

Commit 46a5002

Browse files
committed
Use nlohmann json parser
1 parent 98fa66b commit 46a5002

File tree

6 files changed

+13067
-1819
lines changed

6 files changed

+13067
-1819
lines changed

schedule.cbp

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
<Unit filename="src/cSchedule.h" />
4141
<Unit filename="src/cShop.cpp" />
4242
<Unit filename="src/cShop.h" />
43-
<Unit filename="src/ext/json.cpp" />
44-
<Unit filename="src/ext/json.h" />
43+
<Unit filename="src/ext/json.hpp" />
44+
<Unit filename="src/ext/nlohmann_json.cpp" />
45+
<Unit filename="src/ext/nlohmann_json.hpp" />
4546
<Extensions>
4647
<code_completion />
4748
<envvars />

src/cSchedule.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ cStep::cStep( string name, string machine, float time )
1919

2020

2121

22-
json::Object cStep::json()
22+
nlohmann::json cStep::json()
2323
{
24-
json::Object j;
24+
nlohmann::json j;
2525
j["name"] = myName;
2626
j["machine"] = myMachine;
2727
j["time"] = myTime;
@@ -30,9 +30,9 @@ json::Object cStep::json()
3030
return j;
3131
}
3232

33-
json::Object cJob::json()
33+
nlohmann::json cJob::json()
3434
{
35-
json::Object j;
35+
nlohmann::json j;
3636
j["name"] = myName;
3737
j["earliest"] = myEarliestStart;
3838
switch( myType )
@@ -44,7 +44,7 @@ json::Object cJob::json()
4444
j["type"] = "anyone";
4545
break;
4646
}
47-
json::Array steps;
47+
nlohmann::json steps;
4848
for( auto& s : myStep )
4949
{
5050
steps.push_back( s.json() );
@@ -80,16 +80,21 @@ void cJob::AddSteps( vector< cStep >& vStep )
8080
vStep.push_back( s );
8181
}
8282
}
83+
84+
8385
string cSchedule::json()
8486
{
85-
json::Object s;
86-
json::Array ja;
87+
88+
nlohmann::json s;
89+
nlohmann::json ja;
8790
for( auto& j : myJob )
8891
{
8992
ja.push_back( j.json() );
9093
}
9194
s["jobs"] = ja;
92-
return json::Serialize( s );
95+
string ret;
96+
ret = s.dump();
97+
return ret;
9398
}
9499

95100
void cSchedule::Steps( vector< cStep >& vStep )

src/cSchedule.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <iostream>
22
#include <vector>
3-
#include "json.h"
3+
4+
#include "nlohmann_json.hpp"
45

56
using namespace std;
67

@@ -48,7 +49,7 @@ class cStep
4849
}
4950

5051
/** Output the step in JSON format */
51-
json::Object json();
52+
nlohmann::json json();
5253

5354
/** Name of machine used to process step */
5455
string Machine() const
@@ -156,7 +157,7 @@ class cJob
156157
float time );
157158

158159
/** Job in JSON format */
159-
json::Object json();
160+
nlohmann::json json();
160161

161162
/** Steps in the job
162163
@return new vector containing steps in this job

0 commit comments

Comments
 (0)