README.md 877 Bytes
Newer Older
Karl Herbig's avatar
Karl Herbig committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
JsonPP
======

A C++ Library providing a 'std::string' parser for JavaScript Object Notation. The STL container are in favor to represent the Json entities: Object, Array and Value.

Requirements
------------
C++11/14 standard is required to compile the library.

Code Example
------------

Json:
```json
{
	"user_name":"ccdMuro"
	"user_data":{
		"hobbys":["hacking", "gaming"],
		"age":99
	}
}
```

C++:
Karl Herbig's avatar
Karl Herbig committed
25
```cpp
Karl Herbig's avatar
Karl Herbig committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#include <JsonPP.h>
using namespace Ccd::Json;

...
/* get your Json somehow and store it into the std::string */
...

auto jsonObject = JsonPP::objectFromString(myJsonString);

/* now access the object values with the subscript operator[] */
auto userName = jsonObject["user_name"].toString();
auto userAge = jsonObject["user_data"]["age"].toInt();
auto hobbys = std::vector{};
for ( auto item : jsonObject["user_data"]["hobbys"]){
	hobbys = item.toString();
}
```