set(JSON_C_HEADERS
${JSON_C_PUBLIC_HEADERS}
${PROJECT_SOURCE_DIR}/json_object_private.h
+ ${PROJECT_SOURCE_DIR}/json_pointer_private.h
${PROJECT_SOURCE_DIR}/random_seed.h
${PROJECT_SOURCE_DIR}/strerror_override.h
${PROJECT_SOURCE_DIR}/math_compat.h
JSONC_0.17 {
# global:
# ...new symbols here...
+# array_list_insert_idx is intentionally not exported
} JSONC_0.16;
extern const char *json_hex_chars;
-struct json_pointer_get_result {
- struct json_object *parent;
- struct json_object *obj;
- union {
- const char *key;
- uint32_t index;
- } id;
-};
-
-int json_pointer_get_internal(struct json_object *obj, const char *path,
- struct json_pointer_get_result *res);
-
-typedef int(*json_pointer_array_set_cb)(json_object *parent, size_t idx,
- json_object *value, void *priv);
-
-int json_pointer_set_with_array_cb(struct json_object **obj, const char *path,
- struct json_object *value,
- json_pointer_array_set_cb array_set_cb, void *priv);
-
#ifdef __cplusplus
}
#endif
#include "json_patch.h"
#include "json_object_private.h"
+#include "json_pointer_private.h"
/**
* JavaScript Object Notation (JSON) Patch
int json_patch_apply(struct json_object *base, struct json_object *patch,
struct json_object **res)
{
- size_t i;
+ size_t ii;
int rc = 0;
if (!base || !json_object_is_type(patch, json_type_array)) {
return -1;
/* Go through all operations ; apply them on res */
- for (i = 0; i < json_object_array_length(patch); i++) {
+ for (ii = 0; ii < json_object_array_length(patch); ii++) {
struct json_object *jop, *jpath;
- struct json_object *patch_elem = json_object_array_get_idx(patch, i);
+ struct json_object *patch_elem = json_object_array_get_idx(patch, ii);
const char *op, *path;
if (!json_object_object_get_ex(patch_elem, "op", &jop)) {
errno = EINVAL;
#include "json_object_private.h"
#include "json_pointer.h"
+#include "json_pointer_private.h"
#include "strdup_compat.h"
#include "vasprintf_compat.h"
--- /dev/null
+/*
+ * Copyright (c) 2023 Eric Hawicz
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+#ifndef _json_pointer_private_h_
+#define _json_pointer_private_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct json_pointer_get_result {
+ struct json_object *parent;
+ struct json_object *obj;
+ union {
+ const char *key;
+ uint32_t index;
+ } id;
+};
+
+int json_pointer_get_internal(struct json_object *obj, const char *path,
+ struct json_pointer_get_result *res);
+
+typedef int(*json_pointer_array_set_cb)(json_object *parent, size_t idx,
+ json_object *value, void *priv);
+
+int json_pointer_set_with_array_cb(struct json_object **obj, const char *path,
+ struct json_object *value,
+ json_pointer_array_set_cb array_set_cb, void *priv);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
json_object_put(my_array);
}
+void test_array_insert_idx(void);
void test_array_insert_idx()
{
- json_object *my_string, *my_int, *my_null, *my_object, *my_array;
+ json_object *my_array;
struct json_object *jo1;
my_array = json_object_new_array();
#include <stdio.h>
#include <string.h>
+#include "config.h"
#include "json.h"
+#include "snprintf_compat.h"
#ifndef PATH_MAX
#define PATH_MAX 256
{
char full_filename[PATH_MAX];
(void)snprintf(full_filename, sizeof(full_filename), "%s/%s", testdir, filename);
- int i;
+ size_t ii;
json_object *jo = json_object_from_file(full_filename);
if (!jo) {
exit(EXIT_FAILURE);
}
- for (i = 0; i < json_object_array_length(jo); i++) {
- struct json_object *jo1 = json_object_array_get_idx(jo, i);
+ for (ii = 0; ii < json_object_array_length(jo); ii++) {
+ struct json_object *jo1 = json_object_array_get_idx(jo, ii);
test_json_patch_op(jo1);
}