aboutsummaryrefslogtreecommitdiff
path: root/src/ispeek.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ispeek.c')
-rw-r--r--src/ispeek.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ispeek.c b/src/ispeek.c
index e602125..9e4f8e3 100644
--- a/src/ispeek.c
+++ b/src/ispeek.c
@@ -24,10 +24,10 @@
#include <string.h>
#include <curl/curl.h>
#include "grecs.h"
-#include "grecsopt.h"
+#include "grecs/opt.h"
#include "wordsplit.h"
#include "libeclat.h"
-#include "json.h"
+#include "grecs/json.h"
const char *base_url = "http://169.254.169.254/latest";
@@ -128,29 +128,31 @@ print_file(const char *path, struct closure *cl)
if (argv[0]) {
char *key;
- struct json_object *obj;
+ struct json_value *obj;
static char typestr[] = {
[json_null] = '0',
[json_bool] = 'b',
[json_number] = 'n',
[json_string] = 's',
[json_arr] = 'a',
- [json_obj] = 'o'
+ [json_object] = 'o'
};
obj = json_parse_string(text, strlen(text));
- if (!obj)
- die(EX_DATAERR,
- "%s: near %s",
- json_err_diag,
- json_err_ptr);
+ if (!obj) {
+ char *str = NULL;
+ size_t len = 0;
+ grecs_asprint_locus(&str, &len, &json_err_locus);
+ die(EX_DATAERR, "%s: %s", str, json_err_diag);
+ }
+
while (key = *argv++) {
- struct json_object *p;
+ struct json_value *p;
char *s;
if (print_options & PRINT_NAME)
printf("%s%s", key, delim);
- p = json_object_lookup(obj, key);
+ p = json_value_lookup(obj, key);
if (p) {
if (print_options & PRINT_TYPE)
printf("%c%s", typestr[p->type], delim);
@@ -181,7 +183,7 @@ print_file(const char *path, struct closure *cl)
case json_arr:
printf("array");
break;
- case json_obj:
+ case json_object:
printf("object");
break;
}

Return to:

Send suggestions and report system problems to the System administrator.