aboutsummaryrefslogtreecommitdiff
path: root/src/tests/json.cpp
blob: 6ec92f03fb9b8e0174de443226f260fedf81af14 (plain)
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 <bu/json.h>
#include <bu/file.h>
#include <bu/sio.h>
#include <bu/streamstack.h>

int main( int argc, char *argv[] )
{
    Bu::Json j( "\x01" "ACTION" "\x01" );
    Bu::println( j.toString() );

    Bu::Json ob( Bu::Json::Object );
    ob.insert("hello", 47.0 );
    const Bu::Json &obRef = ob;
    Bu::println("%1").arg( obRef["hello"] );

    return 0;
}

void hi()
{
    Bu::File fIn( "test1.json", Bu::File::Read );
    Bu::Json ob( fIn );
    ob.write( Bu::sioRaw );
    Bu::println("\n");
    Bu::String back1 = ob.toStringStable();
    Bu::Json ob2( back1 );
    Bu::String back2 = ob2.toStringStable();
    Bu::println( back1 );
    Bu::println( back2 );
    if( back1 == back2 )
        Bu::println("loop success");
    else
        Bu::println("loop failure");
}