blob: 44edacdf12f2bdc053681d368d947263de9c73d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include "json.h"
#include <json.hpp>
#include <tokenizer.h>
#include <iostream>
#include <memory>
#include <vector>
using std::cout, std::endl;
int main()
{
TehJSON::JSON jsonWriter;
jsonWriter["test_string"].set<std::string>("stringy");
jsonWriter["test_int"].set<int>(123);
jsonWriter["test_float"].set<float>(51.8);
jsonWriter["test_vecs"]["int"].set<int>({1, 2, 3});
jsonWriter["test_vecs"]["float"].set<float>({0.1, 0.2, 0.3});
jsonWriter["test_true"].set(true);
jsonWriter["test_false"].set(false);
jsonWriter["test_object"]["test_int"].set<int>(100);
jsonWriter["test_object"]["test_float"].set<float>(100);
jsonWriter["test_float"].get<float>() += 15;
jsonWriter["test_object"]["test_int"].get<int>() += 10;
std::string jsonString = jsonWriter.getSerialized();
cout << jsonString << endl;
TehJSON::JSON jsonReader;
cout << "Reading: " << endl;
jsonReader.readFromString(jsonString);
cout << jsonReader.getSerialized() << endl;
}
|