Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e23f558007 | ||
|
|
1894366598 | ||
|
|
7e04530916 | ||
|
|
011e625769 | ||
|
|
de5f2963ab | ||
|
|
128e9c5f37 | ||
|
|
fe6e8eec7e | ||
|
|
addeeef408 | ||
|
|
d82b436b2f | ||
|
|
586b4461e6 | ||
|
|
78418c84f1 | ||
|
|
eb81670881 | ||
|
|
0677666f65 |
@@ -342,7 +342,7 @@ if(JANSSON_BUILD_SHARED_LIBS)
|
||||
)
|
||||
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/jansson.sym")
|
||||
if (VSCRIPT_WORKS)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/jansson.sym")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/jansson.sym")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
3
CONTRIBUTING.md
Normal file
3
CONTRIBUTING.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Hi, and thanks for contributing!
|
||||
|
||||
Please remember to add tests and documentation for new functionality. Backwards incompatible changes or features that are not directly related to JSON are likely to be rejected.
|
||||
31
README.rst
31
README.rst
@@ -26,24 +26,11 @@ data. Its main features and design principles are:
|
||||
Jansson is licensed under the `MIT license`_; see LICENSE in the
|
||||
source distribution for details.
|
||||
|
||||
|
||||
Compilation and Installation
|
||||
----------------------------
|
||||
|
||||
You can download and install Jansson using the `vcpkg <https://github.com/Microsoft/vcpkg/>`_ dependency manager:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
vcpkg install jansson
|
||||
|
||||
The Jansson port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please `create an issue or pull request <https://github.com/Microsoft/vcpkg/>`_ on the vcpkg repository.
|
||||
|
||||
If you obtained a `source tarball`_ from the "Releases" section of the main
|
||||
site just use the standard autotools commands::
|
||||
If you obtained a ``jansson-X.Y.tar.*`` tarball from GitHub Releases, just use
|
||||
the standard autotools commands::
|
||||
|
||||
$ ./configure
|
||||
$ make
|
||||
@@ -53,9 +40,8 @@ To run the test suite, invoke::
|
||||
|
||||
$ make check
|
||||
|
||||
If the source has been checked out from a Git repository, the
|
||||
./configure script has to be generated first. The easiest way is to
|
||||
use autoreconf::
|
||||
If the source has been checked out from a Git repository, the ``configure``
|
||||
script has to be generated first. The easiest way is to use autoreconf::
|
||||
|
||||
$ autoreconf -i
|
||||
|
||||
@@ -74,8 +60,15 @@ Then, point your browser to ``doc/_build/html/index.html``. Sphinx_
|
||||
1.0 or newer is required to generate the documentation.
|
||||
|
||||
|
||||
Community
|
||||
---------
|
||||
|
||||
* `Documentation <http://jansson.readthedocs.io/en/latest/>`_
|
||||
* `Issue tracker <https://github.com/akheron/jansson/issues>`_
|
||||
* `Mailing list <http://groups.google.com/group/jansson-users>`_
|
||||
* `Wiki <https://github.com/akheron/jansson/wiki>`_ contains some development documentation
|
||||
|
||||
.. _Jansson: http://www.digip.org/jansson/
|
||||
.. _`Comprehensive documentation`: http://jansson.readthedocs.io/en/latest/
|
||||
.. _`MIT license`: http://www.opensource.org/licenses/mit-license.php
|
||||
.. _`source tarball`: http://www.digip.org/jansson#releases
|
||||
.. _Sphinx: http://sphinx.pocoo.org/
|
||||
|
||||
@@ -153,6 +153,7 @@ int main(int argc, char *argv[]) {
|
||||
sha = json_object_get(data, "sha");
|
||||
if (!json_is_string(sha)) {
|
||||
fprintf(stderr, "error: commit %d: sha is not a string\n", (int)(i + 1));
|
||||
json_decref(root);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <jansson_private_config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -562,8 +562,7 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap) {
|
||||
long unpacked = 0;
|
||||
|
||||
if (gotopt || json_object_size(root) != key_set.size) {
|
||||
json_object_foreach(root, key, value) {
|
||||
key_len = strlen(key);
|
||||
json_object_keylen_foreach(root, key, key_len, value) {
|
||||
if (!hashtable_get(&key_set, key, key_len)) {
|
||||
unpacked++;
|
||||
|
||||
|
||||
28
src/value.c
28
src/value.c
@@ -191,13 +191,14 @@ int json_object_clear(json_t *json) {
|
||||
|
||||
int json_object_update(json_t *object, json_t *other) {
|
||||
const char *key;
|
||||
size_t key_len;
|
||||
json_t *value;
|
||||
|
||||
if (!json_is_object(object) || !json_is_object(other))
|
||||
return -1;
|
||||
|
||||
json_object_foreach(other, key, value) {
|
||||
if (json_object_set_nocheck(object, key, value))
|
||||
json_object_keylen_foreach(other, key, key_len, value) {
|
||||
if (json_object_setn_nocheck(object, key, key_len, value))
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -222,14 +223,15 @@ int json_object_update_existing(json_t *object, json_t *other) {
|
||||
|
||||
int json_object_update_missing(json_t *object, json_t *other) {
|
||||
const char *key;
|
||||
size_t key_len;
|
||||
json_t *value;
|
||||
|
||||
if (!json_is_object(object) || !json_is_object(other))
|
||||
return -1;
|
||||
|
||||
json_object_foreach(other, key, value) {
|
||||
if (!json_object_get(object, key))
|
||||
json_object_set_nocheck(object, key, value);
|
||||
json_object_keylen_foreach(other, key, key_len, value) {
|
||||
if (!json_object_getn(object, key, key_len))
|
||||
json_object_setn_nocheck(object, key, key_len, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -250,7 +252,7 @@ int do_object_update_recursive(json_t *object, json_t *other, hashtable_t *paren
|
||||
return -1;
|
||||
|
||||
json_object_keylen_foreach(other, key, key_len, value) {
|
||||
json_t *v = json_object_get(object, key);
|
||||
json_t *v = json_object_getn(object, key, key_len);
|
||||
|
||||
if (json_is_object(v) && json_is_object(value)) {
|
||||
if (do_object_update_recursive(v, value, parents)) {
|
||||
@@ -352,13 +354,14 @@ void *json_object_key_to_iter(const char *key) {
|
||||
|
||||
static int json_object_equal(const json_t *object1, const json_t *object2) {
|
||||
const char *key;
|
||||
size_t key_len;
|
||||
const json_t *value1, *value2;
|
||||
|
||||
if (json_object_size(object1) != json_object_size(object2))
|
||||
return 0;
|
||||
|
||||
json_object_foreach((json_t *)object1, key, value1) {
|
||||
value2 = json_object_get(object2, key);
|
||||
json_object_keylen_foreach((json_t *)object1, key, key_len, value1) {
|
||||
value2 = json_object_getn(object2, key, key_len);
|
||||
|
||||
if (!json_equal(value1, value2))
|
||||
return 0;
|
||||
@@ -371,13 +374,15 @@ static json_t *json_object_copy(json_t *object) {
|
||||
json_t *result;
|
||||
|
||||
const char *key;
|
||||
size_t key_len;
|
||||
json_t *value;
|
||||
|
||||
result = json_object();
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
json_object_foreach(object, key, value) json_object_set_nocheck(result, key, value);
|
||||
json_object_keylen_foreach(object, key, key_len, value)
|
||||
json_object_setn_nocheck(result, key, key_len, value);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -400,11 +405,14 @@ static json_t *json_object_deep_copy(const json_t *object, hashtable_t *parents)
|
||||
iter = json_object_iter((json_t *)object);
|
||||
while (iter) {
|
||||
const char *key;
|
||||
size_t key_len;
|
||||
const json_t *value;
|
||||
key = json_object_iter_key(iter);
|
||||
key_len = json_object_iter_key_len(iter);
|
||||
value = json_object_iter_value(iter);
|
||||
|
||||
if (json_object_set_new_nocheck(result, key, do_deep_copy(value, parents))) {
|
||||
if (json_object_setn_new_nocheck(result, key, key_len,
|
||||
do_deep_copy(value, parents))) {
|
||||
json_decref(result);
|
||||
result = NULL;
|
||||
break;
|
||||
|
||||
@@ -15,7 +15,7 @@ grep 'json_\|jansson_' $top_srcdir/src/jansson.def \
|
||||
nm -D $SOFILE >/dev/null >$test_log/symbols 2>/dev/null \
|
||||
|| exit 77 # Skip if "nm -D" doesn't seem to work
|
||||
|
||||
grep ' [DT] ' $test_log/symbols | cut -d' ' -f3 | grep -v '^_' | sort >$test_log/output
|
||||
grep ' [DT] ' $test_log/symbols | cut -d' ' -f3 | grep -v '^_' | sed 's/@@libjansson.*//' | sort >$test_log/output
|
||||
|
||||
if ! cmp -s $test_log/exports $test_log/output; then
|
||||
diff -u $test_log/exports $test_log/output >&2
|
||||
|
||||
@@ -127,6 +127,7 @@ static void test_keylen(void) {
|
||||
|
||||
static void test_invalid_keylen(void) {
|
||||
json_t *obj = json_object();
|
||||
json_t *empty_obj = json_object();
|
||||
const char key[] = {'t', 'e', 's', 't', '1'};
|
||||
|
||||
json_object_set_new_nocheck(obj, "test1", json_true());
|
||||
@@ -149,7 +150,14 @@ static void test_invalid_keylen(void) {
|
||||
if (!json_object_del(obj, NULL))
|
||||
fail("json_object_del with NULL failed");
|
||||
|
||||
if (!json_object_deln(empty_obj, key, sizeof(key)))
|
||||
fail("json_object_deln with empty object failed");
|
||||
|
||||
if (!json_object_deln(obj, key, sizeof(key) - 1))
|
||||
fail("json_object_deln with incomplete key failed");
|
||||
|
||||
json_decref(obj);
|
||||
json_decref(empty_obj);
|
||||
}
|
||||
|
||||
static void test_binary_keys(void) {
|
||||
@@ -166,6 +174,21 @@ static void test_binary_keys(void) {
|
||||
if (!json_is_true(json_object_getn(obj, (const char *)&key1, sizeof(key2))))
|
||||
fail("cannot get integer key2");
|
||||
|
||||
if (json_object_size(obj) != 2)
|
||||
fail("binary object size missmatch");
|
||||
|
||||
if (json_object_deln(obj, (const char *)&key1, sizeof(key1)))
|
||||
fail("cannot del integer key1");
|
||||
|
||||
if (json_object_size(obj) != 1)
|
||||
fail("binary object size missmatch");
|
||||
|
||||
if (json_object_deln(obj, (const char *)&key2, sizeof(key2)))
|
||||
fail("cannot del integer key2");
|
||||
|
||||
if (json_object_size(obj) != 0)
|
||||
fail("binary object size missmatch");
|
||||
|
||||
json_decref(obj);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user