]> git.kaiwu.me - klib.git/commitdiff
kson_query() -> kson_by_path() for clarity
authorHeng Li <lh3@me.com>
Sun, 30 Nov 2014 06:15:00 +0000 (01:15 -0500)
committerHeng Li <lh3@me.com>
Sun, 30 Nov 2014 06:15:00 +0000 (01:15 -0500)
kson.c
kson.h

diff --git a/kson.c b/kson.c
index c5002fb789371c38c4a310b1e346efd57cf0c762..a8bf1601f78b6dd617830fa90759ee673651fce5 100644 (file)
--- a/kson.c
+++ b/kson.c
@@ -135,7 +135,7 @@ kson_t *kson_parse(const char *json)
  *** Query ***
  *************/
 
-const kson_node_t *kson_query(const kson_node_t *p, int depth, ...)
+const kson_node_t *kson_by_path(const kson_node_t *p, int depth, ...)
 {
        va_list ap;
        va_start(ap, depth);
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
        } else {
                kson = kson_parse("{'a' : 1,'b':[0,'isn\\'t',true],'d':[{\n\n\n}]}");
                if (kson) {
-                       const kson_node_t *p = kson_query(kson->root, 2, "b", 1);
+                       const kson_node_t *p = kson_by_path(kson->root, 2, "b", 1);
                        if (p) printf("*** %s\n", p->v.str);
                        else printf("!!! not found\n");
                        kson_format(kson->root);
diff --git a/kson.h b/kson.h
index 9c0eafcedb38f9ccd62a2dfe6d2ec29f8f6a4102..a03eb52f58a3ad4663784973203b5f5b8db55fef 100644 (file)
--- a/kson.h
+++ b/kson.h
@@ -34,7 +34,7 @@ extern "C" {
 
        kson_t *kson_parse(const char *json);
        void kson_destroy(kson_t *kson);
-       const kson_node_t *kson_query(const kson_node_t *root, int max_depth, ...);
+       const kson_node_t *kson_by_path(const kson_node_t *root, int path_len, ...);
        void kson_format(const kson_node_t *root);
 
 #ifdef __cplusplus