test/.gitignore: Add testprogs/test_simple
[jansson.git] / test / loadf_dumpf.c
1 /*
2  * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
3  *
4  * Jansson is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See LICENSE for details.
6  */
7
8 #include <stdio.h>
9 #include <jansson.h>
10
11 int main(int argc, char *argv[])
12 {
13     json_t *json;
14     json_error_t error;
15
16     if(argc != 1) {
17         fprintf(stderr, "usage: %s\n", argv[0]);
18         return 2;
19     }
20
21     json = json_loadf(stdin, &error);
22     if(!json) {
23         fprintf(stderr, "%d\n%s\n", error.line, error.text);
24         return 1;
25     }
26
27     /* loadf_dumpf indents, others don't, so dumping with and without
28        indenting is tested */
29     json_dumpf(json, stdout, JSON_INDENT(4));
30     json_decref(json);
31
32     return 0;
33 }