Skip to content

Commit 0f8bf94

Browse files
committed
parser load <-> loads switch
1 parent 7186401 commit 0f8bf94

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

include/json/parse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

src/parse.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ json::parser::parser(std::string data) : input(data) { return; }
66

77
json::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

2929
json::object json::parser::parseValue() {

0 commit comments

Comments
 (0)