JSON is just text, so there is no C++ JSON or python JSON. For example, this is JSON:
What you need is something to read in the text file, and hold it in memory. For example with the 'jsoncpp' library used in the C++ sample loaders you would do something like this:
Code: Select all
Json::Value bodyValue; // this will hold the file data in memory
Json::Reader reader; // used to read and parse the file
std::ifstream ifs; //input stream
ifs.open( "myfile.json", std::ios::in ); //open the file
reader.parse( ifs, worldValue ); //read the file contents and parse it into memory
ifs.close();
//now you can use the data, eg:
string name = bodyValue.get("name"); // returns 'chris'
Then you would use the data to recreate the Box2D world. Of course, you're dealing with a much more complex JSON file than this example, but the process is the same. I have not used python much to help with it, but I think the first thing you need to do is google "python json parser", to find something to do the parsing step.