-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_test.cpp
81 lines (71 loc) · 2 KB
/
json_test.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "json/process_option.hpp"
#include "json/merge_trees.hpp"
#include "json/find_member.hpp"
#include "json/convert.hpp"
#include <sge/parse/json/output/to_stream.hpp>
#include <sge/parse/json/object.hpp>
#include <sge/parse/json/array.hpp>
#include <sge/parse/json/parse_stream.hpp>
#include <fcppt/io/cout.hpp>
#include <fcppt/io/cerr.hpp>
#include <fcppt/string.hpp>
#include <fcppt/math/dim/dim.hpp>
#include <fcppt/exception.hpp>
#include <fcppt/io/istringstream.hpp>
#include <fcppt/text.hpp>
fcppt::string const
global_json1 =
FCPPT_TEXT("{ \"renderer\" : { \"screen\" : { \"size\" : [1024,768] }, \"foobar\" : 1.0 } }"),
global_json2 =
FCPPT_TEXT("{ \"renderer\" : { \"screen\" : { \"size\" : [640,480],\"is_leet\" : true } } }");
int main(int argc,char *argv[])
try
{
fcppt::io::istringstream
stream1(
global_json1),
stream2(
global_json2);
sge::parse::json::object
o1,
o2;
if(
!sge::parse::json::parse_stream(stream1,o1) ||
!sge::parse::json::parse_stream(stream2,o2))
fcppt::io::cerr << "FFFFUUUUU1!\n";
fcppt::io::cout << "First tree: \n";
sge::parse::json::output::to_stream(
fcppt::io::cout,
o1);
fcppt::io::cout << "\n";
fcppt::io::cout << "Second tree: \n";
sge::parse::json::output::to_stream(
fcppt::io::cout,
o2);
fcppt::io::cout << "\n";
insula::json::process_option(
o1,
FCPPT_TEXT("renderer/screen/size=[640,480]"));
fcppt::io::cout << "First tree after processing: \n";
sge::parse::json::output::to_stream(
fcppt::io::cout,
o1);
fcppt::io::cout << "\n";
fcppt::io::cout << "Trees after merging:\n";
sge::parse::json::output::to_stream(
fcppt::io::cout,
insula::json::merge_trees(
o1,
o2));
fcppt::io::cout << "\n";
fcppt::io::cout << "Resolution found with find_member: " <<
insula::json::find_member<fcppt::math::dim::static_<int,2>::type>(
insula::json::merge_trees(
o1,
o2),
FCPPT_TEXT("renderer/screen/size")) << "\n";
}
catch (fcppt::exception const &e)
{
fcppt::io::cout << "Fehler: " << e.string() << "\n";
}