Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
sudo ldconfig
- name: Build and test json-c/yyjson
run: |
./configure --asan
make
make tests-c
- name: build and test python
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ YYJSON_LDFLAGS=$(shell pkg-config --libs yyjson)

include config.mk

all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union
all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors

YYJSON_TESTS=test-yyjson

Expand Down Expand Up @@ -43,10 +43,16 @@ test-json-get-array-big-index: tests/json-c/get-array-big-index.c csonpath_json-
test-json-union: tests/json-c/union.c csonpath_json-c.h csonpath.h csonpath_do.h
$(CC) tests/json-c/union.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-union $(JSON_C_LDFLAGS) $(LDFLAGS)

test-json-audit-bugs: tests/json-c/audit-bugs.c csonpath_json-c.h csonpath.h csonpath_do.h
$(CC) tests/json-c/audit-bugs.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-audit-bugs $(JSON_C_LDFLAGS) $(LDFLAGS)

test-json-crash-vectors: tests/json-c/crash-vectors.c csonpath_json-c.h csonpath.h csonpath_do.h
$(CC) tests/json-c/crash-vectors.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-crash-vectors $(JSON_C_LDFLAGS) $(LDFLAGS)

test-yyjson: tests/yyjson/test-yyjson.c csonpath_yyjson.h csonpath.h csonpath_do.h
$(CC) tests/yyjson/test-yyjson.c $(EXTRA_FILES) $(YYJSON_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-yyjson $(YYJSON_LDFLAGS) $(LDFLAGS)

tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-yyjson
tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-yyjson
./test-json-c-get-a
./test-json-update
./test-json-filter
Expand All @@ -55,6 +61,8 @@ test-yyjson: tests/yyjson/test-yyjson.c csonpath_yyjson.h csonpath.h csonpath_do
./test-json-filter-and-missing-key
./test-json-get-array-big-index
./test-json-union
./test-json-audit-bugs
./test-json-crash-vectors
./test-yyjson

pip-dev:
Expand All @@ -66,5 +74,5 @@ tests-py: pip-dev
tests: tests-py tests-c

clean:
rm -rvf test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-yyjson
rm -rvf test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-yyjson

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Unlike many JSONPath libraries, csonpath is **backend-agnostic**: it can work wi
| Array index | `$.array[0]` | Access by zero-based index |
| Wildcard `[*]` | `$.array[*].field` | Iterate all array elements |
| Recursive descent `..` | `$..name` | Search recursively for a key |
| Union `\|` / `,` | `$.a \| $.b` or `$['a','b']` | Match multiple paths at once |
| Union `,` (inside brackets) | `$['a','b']`, `$.array[0,1]`, `$.items[?n==1, ?n==2]` | Match all listed selectors at once |
| OR fallback `\|` | `$.a \| $.b` | Try the left path first; fall back to the right one if it does not match. Only the first successful path is used. |
| Filters | `$.items[?price > 10]` | Filter array elements |
| Regex filters | `$.items[?name =~ "foo"]` | POSIX regex-based filtering |
| Multiple filters (`&`) | `$.items[?a=1 & b=2]` | Combine conditions |
Expand Down
5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ for arg in $@; do
CFLAGS="${CFLAGS} -DCSONPATH_PCRE2_POSIX $(pkg-config --cflags libpcre2-posix)"
LDFLAGS="${LDFLAGS} $(pkg-config --libs libpcre2-posix)"
fi
if [ "--asan" = $arg ]; then
CFLAGS="${CFLAGS} -fsanitize=address -fno-omit-frame-pointer"
LDFLAGS="${LDFLAGS} -fsanitize=address"
fi
if [ "--help" = $arg ]; then
echo "help"
echo " --tiny-regex"
echo " --pcre2-regex"
echo " --pcre2-posix"
echo " --no-regex"
echo " --asan"
fi
done

Expand Down
Loading
Loading