I use the boost property tree to load a jump file. However, performance is very poor.
For example, I have a json file 1.8M in size. A C ++ program for acceleration takes 3 seconds to load a json file and build a property tree. If I use python to load a json file, it only takes 0.1 second. And python will also build everything as an object.
A C ++ program is similar to:
int main(int argc, char **argv){ std::fstream fin; fin.open(argv[1], std::fstream::in); if (!fin.is_open()){ ASSERT(false); } boost::property_tree::ptree pt; try{ read_json(fin, pt); }catch(ptree_error & e) { ASSERT(false); } fin.close(); return 0; }
A python script that does the same looks like this:
#!/usr/bin//python import sys import json fp = open(sys.argv[1],"r") objs = json.load(fp)
I tried the last impulse (1.54). It is still very slow.
Appreciate any advice.
If there is no solution, do you know any other C ++ library for loading / unloading json?
source share