File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ int main(int argc, char **argv) {
2222 std::cout << person << std::endl << std::endl;
2323
2424 parser jsonParser;
25- object obj = jsonParser.load (person.dumps (2 ));
25+ object obj = jsonParser.loads (person.dumps (2 ));
2626 std::cout << obj.dumps (4 ) << std::endl;
2727
2828 return EXIT_SUCCESS;
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ class parser {
3131 parser (std::string data);
3232 ~parser ();
3333
34- object load (std::string data );
35- object loads (std::string path );
34+ object load (std::string path );
35+ object loads (std::string data );
3636};
3737
3838} // namespace json
Original file line number Diff line number Diff line change @@ -6,15 +6,7 @@ json::parser::parser(std::string data) : input(data) { return; }
66
77json::parser::~parser () { return ; }
88
9- json::object json::parser::load (std::string data) {
10- this ->input = data;
11- this ->index = 0 ;
12- this ->output .reset ();
13-
14- this ->output = this ->parseValue ();
15- return this ->output ;
16- }
17- json::object json::parser::loads (std::string path) {
9+ json::object json::parser::load (std::string path) {
1810 std::ifstream file (path);
1911 if (!file.is_open ())
2012 throw std::runtime_error (" File not found" );
@@ -23,7 +15,15 @@ json::object json::parser::loads(std::string path) {
2315 buffer << file.rdbuf ();
2416 file.close ();
2517
26- return this ->load (buffer.str ());
18+ return this ->loads (buffer.str ());
19+ }
20+ json::object json::parser::loads (std::string data) {
21+ this ->input = data;
22+ this ->index = 0 ;
23+ this ->output .reset ();
24+
25+ this ->output = this ->parseValue ();
26+ return this ->output ;
2727}
2828
2929json::object json::parser::parseValue () {
You can’t perform that action at this time.
0 commit comments