2 * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
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.
12 static int getenv_int(const char *name)
21 result = strtol(value, &end, 10);
28 int main(int argc, char *argv[])
31 unsigned int flags = 0;
37 fprintf(stderr, "usage: %s\n", argv[0]);
41 indent = getenv_int("JSON_INDENT");
42 if(indent < 0 || indent > 255) {
43 fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent);
48 flags |= JSON_INDENT(indent);
50 if(getenv_int("JSON_COMPACT") > 0)
51 flags |= JSON_COMPACT;
53 if(getenv_int("JSON_ENSURE_ASCII"))
54 flags |= JSON_ENSURE_ASCII;
56 if(getenv_int("JSON_SORT_KEYS"))
57 flags |= JSON_SORT_KEYS;
59 json = json_loadf(stdin, &error);
61 fprintf(stderr, "%d\n%s\n", error.line, error.text);
65 json_dumpf(json, stdout, flags);