blob: 00fca0331586e182087250c986da08e2b2d756e0 (
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
36
|
#include <json.hpp>
#include <tokenizer.h>
#include <iostream>
#include <memory>
using std::cout, std::endl;
int main()
{
TehJSON::JSON jsonWriter;
// TestClass test1;
// json["test1"].set(test1);
jsonWriter["test_string"].set<std::string>("stringy");
jsonWriter["test_int"].set<int>(123);
jsonWriter["test_float"].set<float>(51.8);
jsonWriter["test_object"]["test_int"].set<int>(100);
jsonWriter["test_object"]["test_float"].set<float>(100);
std::string jsonString = jsonWriter.getSerialized();
cout << jsonString << endl;
// TehJSON::Tokenizer tokenizer;
// tokenizer.appendInput(jsonString);
// std::vector<TehJSON::Token> tokens = tokenizer.tokenize();
// for(const auto& token : tokens)
// {
// cout << TehJSON::getTokenName(token.type) << ": " << token.content << endl;
// }
TehJSON::JSON jsonReader;
cout << "Reading: " << endl;
jsonReader.readFromString(jsonString);
cout << jsonReader.getSerialized() << endl;
}
|