https://github.com/heapwolf/json
Better JSON handling for C++
https://github.com/heapwolf/json
Last synced: 5 months ago
JSON representation
Better JSON handling for C++
- Host: GitHub
- URL: https://github.com/heapwolf/json
- Owner: heapwolf
- License: mit
- Created: 2014-05-29T12:28:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-22T22:32:15.000Z (about 11 years ago)
- Last Synced: 2025-05-18T14:49:15.435Z (6 months ago)
- Language: C
- Size: 793 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SYNOPSIS
a tiny helper for using dropbox's json11 parser. because constructing json in C++ is ugly.
# EXAMPLE
```cc
#include
#include "json/json.h"
using namespace std;
using namespace JSON;
int main() {
auto foo = JSON({
"hello": "world",
"data": [0, null, ["hello", "goodbye"]], // awesome
"quote": {
"O'Connor": "everything that rises must converge"
}
});
cout << foo["quote"]["O'Connor"].string_value() << endl;
}
```
Or just pass a string in, use try catch if your involved in some risky business.
```
auto foo = JSON(my_json_string);
cout << foo << endl;
```
# INCLUDE
just include the header file
# COMPILE EXAMPLE
Just link to the built binary (or modify and rebuild yourself).
```bash
cd example
g++ -O0 -std=c++1y ./example/literal.cc ./deps/json11/json11.cpp -o example
```