test/.gitignore: Add testprogs/test_simple
[jansson.git] / test / load_file_dump_file.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 != 3) {
17         fprintf(stderr, "usage: %s infile outfile\n", argv[0]);
18         return 2;
19     }
20
21     json = json_load_file(argv[1], &error);
22     if(!json) {
23         fprintf(stderr, "%d\n%s\n", error.line, error.text);
24         return 1;
25     }
26
27     json_dump_file(json, argv[2], 0);
28     json_decref(json);
29
30     return 0;
31 }