Hello. So I made a header library for parsing JSON. Im not too experienced with C++ so it's probably not the best. I only started C++ about a month and a half ago.
About The Project
So basically its a JSON Parser in C++.
It can parse a JSON String into an Object that can be used within your project.
Here are some methods with the JSON class.
JSONObject JSON::readFromFile(std::string); JSONObject JSON::parse(std::string); std::string JSON::stringify(JSONObject);
You can use subscripts on the object to access different values in the object.
JSONObject x = JSON::readFromFile(std::string); x["hello"] = "world"; // To get a value use .getTYPE(); std::cout << x["hello"].getString();
There are many methods to get the value. These should be used on the subscript.
std::string getString(); int getInt(); double getDouble(); bool getBoolean();
Right now it can parse I think everything in JSON. It can do arrays, objects, integers, doubles, null, undefined, and booleans.
You can also nest objects and arrays into each other.
For arrays using the subscript is the same as any other array:
// x is defined JSONObject and it is an array // [2, 4, 5, 6] std::cout << x.getInt() << std::endl; // -> 2
There is no way to get the length of the array yet so...
Also cannot initialize an array easily either. But Im still working on it so maybe in the future.
But thats basically it. It might not be the most performant. I didn't really test performance I just wanted it to work so. Thanks.