File: catjson.c

package info (click to toggle)
libcatmandu-fix-cmd-perl 0.0201-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 56; java: 15; ansic: 15; lisp: 8; makefile: 8; python: 6
file content (24 lines) | stat: -rw-r--r-- 507 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * This code uses the json-c library
 *
 * gcc -l json -o catjson catjson-c.c
 *
 * Patrick . Hochstenbach @ UGent . be
 */
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <json/json.h>

int main(int argc, char *argv[]) {
    char *line = NULL;
    size_t size;
    json_object *new_obj;

    while (getline(&line, &size, stdin) != -1) {
       new_obj = json_tokener_parse(line);
       printf("%s\n", json_object_to_json_string(new_obj));
    }
    return 0;
}