Ticket #11104: JsonTest.cpp

File JsonTest.cpp, 435 bytes (added by waddlesplash, 10 years ago)

JSON tester, compile with g++ -g JsonTest.cpp haiku/src/kits/shared/Json.cpp haiku/src/kits/shared/MessageBuilder.cpp -Ihaiku/headers/private/shared/ -o jsontest -lbe

Line 
1/*
2 * Copyright 2014, Augustin Cavalier (waddlesplash)
3 * Distributed under the terms of the MIT License.
4 */
5
6#include <Json.h>
7#include <File.h>
8#include <stdlib.h>
9
10int main(int argc, char* argv[])
11{
12 BFile f("test.json", B_READ_ONLY);
13 off_t size = 0;
14 f.GetSize(&size);
15 char* json = (char*)malloc(size);
16
17 if (f.Read(json, size) > 0) {
18 BMessage msg;
19 BPrivate::BJson::Parse(msg, json);
20 msg.PrintToStream();
21 }
22
23 return 0;
24}