-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_fixer.cpp
More file actions
23 lines (19 loc) · 741 Bytes
/
json_fixer.cpp
File metadata and controls
23 lines (19 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <SSVUtilsJson/SSVUtilsJson.h>
#include <SSVJsonCpp/SSVJsonCpp.h>
#include <pybind11/pybind11.h>
#include <iostream>
#include <fstream>
std::string fix_json_file(std::string file) {
Json::Value root = ssvuj::getRootFromFile(file);
Json::FastWriter fastwriter;
return fastwriter.write(root);
}
std::string fix_json_string(std::string string) {
Json::Value root = ssvuj::getRootFromString(string);
Json::FastWriter fastwriter;
return fastwriter.write(root);
}
PYBIND11_MODULE(json_fixer, m) {
m.def("fix_json_file", &fix_json_file, "A function that reads a JSON file in a very lenient way");
m.def("fix_json_string", &fix_json_string, "A function that reads a JSON string in a very lenient way");
}