forked from nbsdx/SimpleJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiter_example.cpp
More file actions
50 lines (38 loc) · 1.15 KB
/
Copy pathiter_example.cpp
File metadata and controls
50 lines (38 loc) · 1.15 KB
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
#include "json.hpp"
#include <iostream>
using json::JSON;
using namespace std;
void dumpArrayConst( const JSON &array ) {
for( auto &j : array.ArrayRange() )
std::cout << "Value: " << j << "\n";
}
void dumpArray( JSON &array ) {
for( auto &j : array.ArrayRange() )
std::cout << "Value: " << j << "\n";
}
void dumpObjectConst( const JSON &object ) {
for( auto &j : object.ObjectRange() )
std::cout << "Object[ " << j.first << " ] = " << j.second << "\n";
}
void dumpObject( JSON &object ) {
for( auto &j : object.ObjectRange() )
std::cout << "Object[ " << j.first << " ] = " << j.second << "\n";
}
int main()
{
JSON array = JSON::Make( JSON::Class::Array );
JSON obj = JSON::Make( JSON::Class::Object );
array[0] = "Test0";
array[1] = "Test1";
array[2] = "Test2";
array[3] = "Test3";
obj[ "Key0" ] = "Value1";
obj[ "Key1" ] = array;
obj[ "Key2" ] = 123;
std::cout << "=============== tests ================\n";
dumpArray( array );
dumpObject( obj );
std::cout << "============ const tests =============\n";
dumpArrayConst( array );
dumpObjectConst( obj );
}