39 lines
851 B
C
39 lines
851 B
C
#include <blue/core/stream.h>
|
|
#include <blue/ds/array.h>
|
|
#include <blue/ds/dict.h>
|
|
#include <blue/ds/number.h>
|
|
#include <blue/ds/string.h>
|
|
#include <blue/serial.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
b_serial_ctx *ctx;
|
|
b_serial_ctx_create(&ctx);
|
|
|
|
b_dict *dict = b_dict_create();
|
|
|
|
b_array *array = b_array_create();
|
|
b_array_append(array, B_RV_INT(32));
|
|
b_array_append(array, B_RV_INT(64));
|
|
b_array_append(array, B_RV_INT(128));
|
|
|
|
b_dict_put(dict, "numbers", B_RV(array));
|
|
|
|
array = b_array_create();
|
|
b_array_append(array, B_RV_CSTR("hello"));
|
|
b_array_append(array, B_RV_CSTR("world"));
|
|
|
|
b_dict_put(dict, "strings", B_RV(array));
|
|
|
|
b_object_to_string(dict, b_stdout);
|
|
b_stream_write_char(b_stdout, '\n');
|
|
|
|
b_serial_ctx_serialise(ctx, B_SERIAL_FORMAT_JSON, dict, b_stdout, 0);
|
|
|
|
b_dict_unref(dict);
|
|
b_serial_ctx_destroy(ctx);
|
|
|
|
return 0;
|
|
}
|