change behavior of expanding json paths with arrays
This commit is contained in:
parent
6d52922c22
commit
c3eb0fd8e2
@ -481,7 +481,6 @@ parse_path (json_t *obj,
|
|||||||
'.');
|
'.');
|
||||||
char *next_path;
|
char *next_path;
|
||||||
char *bracket;
|
char *bracket;
|
||||||
json_t *parent = obj;
|
|
||||||
json_t *next_obj = NULL;
|
json_t *next_obj = NULL;
|
||||||
|
|
||||||
if (NULL != next_id)
|
if (NULL != next_id)
|
||||||
@ -522,15 +521,15 @@ parse_path (json_t *obj,
|
|||||||
*bracket = '\0';
|
*bracket = '\0';
|
||||||
bracket++;
|
bracket++;
|
||||||
|
|
||||||
parent = json_object_get (obj,
|
json_t *array = json_object_get (obj,
|
||||||
next_id);
|
next_id);
|
||||||
if (0 == strcmp (bracket,
|
if (0 == strcmp (bracket,
|
||||||
"*"))
|
"*"))
|
||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
json_t *value;
|
json_t *value;
|
||||||
int ret = GNUNET_OK;
|
int ret = GNUNET_OK;
|
||||||
json_array_foreach (parent, index, value) {
|
json_array_foreach (array, index, value) {
|
||||||
ret = parse_path (value,
|
ret = parse_path (value,
|
||||||
obj,
|
obj,
|
||||||
next_path,
|
next_path,
|
||||||
@ -550,7 +549,7 @@ parse_path (json_t *obj,
|
|||||||
"%u",
|
"%u",
|
||||||
&index))
|
&index))
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
next_obj = json_array_get (parent,
|
next_obj = json_array_get (array,
|
||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,7 +563,7 @@ parse_path (json_t *obj,
|
|||||||
if (NULL != next_obj)
|
if (NULL != next_obj)
|
||||||
{
|
{
|
||||||
return parse_path (next_obj,
|
return parse_path (next_obj,
|
||||||
parent,
|
obj,
|
||||||
next_path,
|
next_path,
|
||||||
cb,
|
cb,
|
||||||
cb_cls);
|
cb_cls);
|
||||||
|
@ -236,26 +236,6 @@ test_contract ()
|
|||||||
GNUNET_assert (3 == tp.results_length);
|
GNUNET_assert (3 == tp.results_length);
|
||||||
GNUNET_assert (0 == tp.cmp_result);
|
GNUNET_assert (0 == tp.cmp_result);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
const char *object_ids[] = { "fruit[0]" };
|
|
||||||
const json_t *parents[] = {
|
|
||||||
json_object_get (c4,
|
|
||||||
"fruit")
|
|
||||||
};
|
|
||||||
struct TestPath_Closure tp = {
|
|
||||||
.object_ids = object_ids,
|
|
||||||
.parents = parents,
|
|
||||||
.results_length = 0,
|
|
||||||
.cmp_result = 0
|
|
||||||
};
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
|
||||||
TALER_JSON_expand_path (c4,
|
|
||||||
"$.fruit[0]",
|
|
||||||
&path_cb,
|
|
||||||
&tp));
|
|
||||||
GNUNET_assert (1 == tp.results_length);
|
|
||||||
GNUNET_assert (0 == tp.cmp_result);
|
|
||||||
}
|
|
||||||
json_decref (c4);
|
json_decref (c4);
|
||||||
if (0 !=
|
if (0 !=
|
||||||
GNUNET_memcmp (&h1,
|
GNUNET_memcmp (&h1,
|
||||||
|
Loading…
Reference in New Issue
Block a user