pax_global_header00006660000000000000000000000064145661504610014522gustar00rootroot0000000000000052 comment=a348f59f0b55d92a1364523560f52f5b3cf9c12a orjson-3.9.15/000077500000000000000000000000001456615046100131335ustar00rootroot00000000000000orjson-3.9.15/.gitattributes000066400000000000000000000000351456615046100160240ustar00rootroot00000000000000include/** linguist-vendored orjson-3.9.15/.github/000077500000000000000000000000001456615046100144735ustar00rootroot00000000000000orjson-3.9.15/.github/workflows/000077500000000000000000000000001456615046100165305ustar00rootroot00000000000000orjson-3.9.15/.github/workflows/debug.yaml000066400000000000000000000032071456615046100205040ustar00rootroot00000000000000name: debug on: push jobs: debug: runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: profile: [ { rust: "1.72", features: "" }, { rust: "1.72", features: "--features=yyjson" }, { rust: "nightly-2024-02-13", features: "--features=yyjson,unstable-simd" }, ] python: [ { version: '3.13' }, { version: '3.12' }, { version: '3.8' }, ] env: CC: "gcc" CFLAGS: "-O2" LDFLAGS: "-Wl,--as-needed" CARGO_UNSTABLE_SPARSE_REGISTRY: "true" steps: - run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain ${{ matrix.profile.rust }} --profile minimal -y - uses: actions/setup-python@v5 with: allow-prereleases: true python-version: '${{ matrix.python.version }}' - run: python -m pip install --user --upgrade pip "maturin>=1,<2" wheel - uses: actions/checkout@v4 - name: build run: | PATH="$HOME/.cargo/bin:$PATH" maturin build --release \ --out=dist \ --profile=dev \ --interpreter python${{ matrix.python.version }} \ --target=x86_64-unknown-linux-gnu ${{ matrix.profile.features }} - run: python -m pip install --user dist/orjson*.whl - run: python -m pip install --user -r test/requirements.txt -r integration/requirements.txt - run: pytest -s -rxX -v test timeout-minutes: 4 env: PYTHONMALLOC: "debug" - run: ./integration/run thread timeout-minutes: 2 - run: ./integration/run http timeout-minutes: 2 - run: ./integration/run init timeout-minutes: 2 orjson-3.9.15/.github/workflows/lint.yaml000066400000000000000000000007441456615046100203670ustar00rootroot00000000000000name: lint on: push jobs: lint: runs-on: ubuntu-22.04 steps: - uses: actions/setup-python@v5 with: python-version: '3.11' - run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=default -y - run: pip install -U autoflake isort black ruff mypy types-python-dateutil types-pytz types-simplejson types-ujson - uses: actions/checkout@v4 - run: cargo fmt - run: ./script/lint - run: git diff --exit-code orjson-3.9.15/.github/workflows/linux.yaml000066400000000000000000000236211456615046100205570ustar00rootroot00000000000000name: linux on: push jobs: sdist: runs-on: ubuntu-22.04 strategy: fail-fast: false env: RUST_TOOLCHAIN: "1.72" # MSRV steps: - run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y - run: rustup default $RUST_TOOLCHAIN - uses: actions/checkout@v4 - run: python3 -m pip install --user --upgrade pip "maturin>=1,<2" wheel - run: maturin build - run: cargo fetch - run: mkdir .cargo - run: cp ci/sdist.toml .cargo/config.toml - run: cargo vendor include/cargo --versioned-dirs - run: maturin sdist --out=dist - run: python3 -m pip install --user dist/orjson*.tar.gz env: CARGO_NET_OFFLINE: "true" - run: python3 -m pip install --user -r test/requirements.txt -r integration/requirements.txt mypy - run: pytest -s -rxX -v test env: PYTHONMALLOC: "debug" - run: ./integration/run thread - run: ./integration/run http - run: ./integration/run init - run: ./integration/run typestubs - name: Store sdist if: "startsWith(github.ref, 'refs/tags/')" uses: actions/upload-artifact@v3 with: name: wheels path: dist retention-days: 1 manylinux_2_17_amd64: runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: python: [ { version: '3.12', abi: 'cp312-cp312' }, { version: '3.11', abi: 'cp311-cp311' }, { version: '3.10', abi: 'cp310-cp310' }, { version: '3.9', abi: 'cp39-cp39' }, { version: '3.8', abi: 'cp38-cp38' }, ] env: PATH: /github/home/.local/bin:/github/home/.cargo/bin:/opt/python/${{ matrix.python.abi }}/bin:/opt/rh/gcc-toolset-12/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CC: "clang" CFLAGS: "-O2 -fstrict-aliasing -emit-llvm -flto=full" LDFLAGS: "-O2 -fstrict-aliasing -emit-llvm -flto=full -fuse-ld=lld -Wl,--as-needed -Wl,-plugin-opt=also-emit-llvm" RUSTFLAGS: "-C linker=clang -C linker-plugin-lto -C lto=fat -C link-arg=-fuse-ld=lld -Z mir-opt-level=4 -Z virtual-function-elimination -D warnings" CARGO_UNSTABLE_SPARSE_REGISTRY: "true" container: image: quay.io/pypa/manylinux_2_28_x86_64:latest options: --user 0 steps: - run: yum install -y clang lld - run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-02-13 --profile minimal -y - run: rustup component add rust-src --toolchain nightly-2024-02-13-x86_64-unknown-linux-gnu - uses: actions/checkout@v4 - name: build-std run: | mkdir .cargo cp ci/config.toml .cargo/config.toml - run: python3 -m pip install --user --upgrade pip "maturin>=1,<2" wheel - run: | maturin build --release --strip \ --out=dist \ --features=no-panic,unstable-simd,yyjson \ --compatibility manylinux_2_17 \ --interpreter python${{ matrix.python.version }} \ --target=x86_64-unknown-linux-gnu - run: python3 -m pip install --user dist/orjson*.whl - run: python3 -m pip install --user -r test/requirements.txt -r integration/requirements.txt - run: pytest -s -rxX -v test env: PYTHONMALLOC: "debug" - run: ./integration/run thread - run: ./integration/run http - run: ./integration/run init - name: Store wheels if: "startsWith(github.ref, 'refs/tags/')" uses: actions/upload-artifact@v3 with: name: wheels path: dist retention-days: 1 musllinux_1_2: runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: python: [ { version: '3.12' }, { version: '3.11' }, { version: '3.10' }, { version: '3.9' }, { version: '3.8' }, ] platform: - target: aarch64-unknown-linux-musl arch: aarch64 platform: linux/arm64 - target: x86_64-unknown-linux-musl arch: x86_64 platform: linux/amd64 steps: - uses: actions/checkout@v4 - name: build-std run: | mkdir .cargo cp ci/config.toml .cargo/config.toml - name: Build uses: PyO3/maturin-action@v1 env: CC: "gcc" CFLAGS: "-O2" LDFLAGS: "-O2 -flto -Wl,--as-needed" RUSTFLAGS: "-C target-feature=-crt-static -Z mir-opt-level=4" CARGO_UNSTABLE_SPARSE_REGISTRY: "true" with: rust-toolchain: nightly-2024-02-13 rustup-components: rust-src target: ${{ matrix.platform.target }} manylinux: musllinux_1_2 args: --release --strip --out=dist --features=no-panic,unstable-simd,yyjson -i python${{ matrix.python.version }} - name: Set up QEMU if: matrix.platform.arch != 'x86_64' uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v8.1.4 platforms: ${{ matrix.platform.platform }} - name: Test uses: addnab/docker-run-action@v3 with: image: quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:latest options: -v ${{ github.workspace }}:/io -w /io run: | apk add tzdata sed -i '/^psutil/d' test/requirements.txt # missing 3.11, 3.12 wheels sed -i '/^numpy/d' test/requirements.txt python${{ matrix.python.version }} -m venv venv venv/bin/pip install -U pip wheel venv/bin/pip install -r test/requirements.txt venv/bin/pip install orjson --no-index --find-links dist/ --force-reinstall venv/bin/python -m pytest -s -rxX -v test - name: Store wheels if: "startsWith(github.ref, 'refs/tags/')" uses: actions/upload-artifact@v3 with: name: wheels path: dist retention-days: 1 manylinux_2_17_non_amd64: runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: python: [ { version: '3.12', abi: 'cp312-cp312' }, { version: '3.11', abi: 'cp311-cp311' }, { version: '3.10', abi: 'cp310-cp310' }, { version: '3.9', abi: 'cp39-cp39' }, { version: '3.8', abi: 'cp38-cp38' }, ] target: [ { arch: 'aarch64', cflags: '-O2 -flto', features: 'no-panic,unstable-simd,yyjson', rustflags: '-Z mir-opt-level=4 -D warnings', target: 'aarch64-unknown-linux-gnu', }, { arch: 'armv7', cflags: '-Os -flto -fstrict-aliasing', features: 'no-panic,yyjson', # no SIMD rustflags: '-C opt-level=s -Z mir-opt-level=4 -D warnings', target: 'armv7-unknown-linux-gnueabihf', }, { arch: 'ppc64le', cflags: '-O2 -flto', features: 'no-panic,unstable-simd,yyjson', rustflags: '-Z mir-opt-level=4 -D warnings', target: 'powerpc64le-unknown-linux-gnu', }, { arch: 's390x', cflags: '-O2 -flto -march=z10', # no unstable-simd as rotate_elements_left() causes exit 125 in at least QEMU features: 'no-panic,yyjson', rustflags: '-Z mir-opt-level=4 -C target-cpu=z10 -D warnings', target: 's390x-unknown-linux-gnu', }, ] steps: - uses: actions/checkout@v4 - name: build-std run: | mkdir .cargo cp ci/config.toml .cargo/config.toml - name: Build uses: PyO3/maturin-action@v1 env: PYO3_CROSS_LIB_DIR: "/opt/python/${{ matrix.python.abi }}" CFLAGS: "${{ matrix.target.cflags }}" LDFLAGS: "${{ matrix.target.cflags }} -Wl,--as-needed" CARGO_UNSTABLE_SPARSE_REGISTRY: "true" RUSTFLAGS: "${{ matrix.target.rustflags }}" with: target: ${{ matrix.target.target }} rust-toolchain: nightly-2024-02-13 rustup-components: rust-src manylinux: auto args: --release --strip --out=dist --features=${{ matrix.target.features }} -i python${{ matrix.python.version }} - uses: uraimo/run-on-arch-action@v2 name: Test with: arch: ${{ matrix.target.arch }} distro: ubuntu22.04 githubToken: ${{ github.token }} install: | export TZ=UTC export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y --no-install-recommends software-properties-common gpg gpg-agent curl add-apt-repository ppa:deadsnakes/ppa apt-get update apt-get install -y python${{ matrix.python.version }}-dev python${{ matrix.python.version }}-venv run: | python${{ matrix.python.version }} -m venv venv venv/bin/pip install -U pip wheel venv/bin/pip install -r test/requirements.txt venv/bin/pip install orjson --no-index --find-links dist/ --force-reinstall venv/bin/python -m pytest -s -rxX -v test - name: Store wheels if: "startsWith(github.ref, 'refs/tags/')" uses: actions/upload-artifact@v3 with: name: wheels path: dist retention-days: 1 pypi: name: PyPI permissions: # trusted publisher id-token: write contents: write runs-on: ubuntu-22.04 if: "startsWith(github.ref, 'refs/tags/')" needs: [ manylinux_2_17_amd64, manylinux_2_17_non_amd64, musllinux_1_2, sdist ] steps: - uses: actions/download-artifact@v3 with: name: wheels - uses: actions/setup-python@v5 with: python-version: "3.11" - run: pip install pip "maturin>=1,<2" - run: ls -1 . - name: deploy wheel run: maturin upload --skip-existing --username "$MATURIN_USERNAME" *.whl env: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - name: deploy sdist run: maturin upload --skip-existing --username "$MATURIN_USERNAME" *.tar.gz env: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} orjson-3.9.15/.github/workflows/stale.yaml000066400000000000000000000004111456615046100205200ustar00rootroot00000000000000name: stale on: schedule: - cron: '0 8 * * *' permissions: issues: write pull-requests: write jobs: stale: runs-on: ubuntu-latest steps: - uses: actions/stale@v8 with: days-before-stale: 7 days-before-close: 1 orjson-3.9.15/.gitignore000066400000000000000000000001761456615046100151270ustar00rootroot00000000000000*.patch /.benchmarks /.coverage /.mypy_cache /.pytest_cache /.venv* /build /include/cargo /perf.* /target /vendor __pycache__ orjson-3.9.15/CHANGELOG.md000066400000000000000000000471441456615046100147560ustar00rootroot00000000000000# Changelog ## 3.9.15 - 2024-02-23 ### Fixed - Implement recursion limit of 1024 on `orjson.loads()`. - Use byte-exact read on `str` formatting SIMD path to avoid crash. ## 3.9.14 - 2024-02-14 ### Fixed - Fix crash serializing `str` introduced in 3.9.11. ### Changed - Build now depends on Rust 1.72 or later. ## 3.9.13 - 2024-02-03 ### Fixed - Serialization `str` escape uses only 128-bit SIMD. - Fix compatibility with CPython 3.13 alpha 3. ### Changed - Publish `musllinux_1_2` instead of `musllinux_1_1` wheels. - Serialization uses small integer optimization in CPython 3.12 or later. ## 3.9.12 - 2024-01-18 ### Changed - Update benchmarks in README. ### Fixed - Minimal `musllinux_1_1` build due to sporadic CI failure. ## 3.9.11 - 2024-01-18 ### Changed - Improve performance of serializing. `str` is significantly faster. Documents using `dict`, `list`, and `tuple` are somewhat faster. ## 3.9.10 - 2023-10-26 ### Fixed - Fix debug assert failure on 3.12 `--profile=dev` build. ## 3.9.9 - 2023-10-12 ### Changed - `orjson` module metadata explicitly marks subinterpreters as not supported. ## 3.9.8 - 2023-10-10 ### Changed - Improve performance. - Drop support for Python 3.7. ## 3.9.7 - 2023-09-08 ### Fixed - Fix crash in `orjson.loads()` due to non-reentrant handling of persistent buffer. This was introduced in 3.9.3. - Handle some FFI removals in CPython 3.13. ## 3.9.6 - 2023-09-07 ### Fixed - Fix numpy reference leak on unsupported array dtype. - Fix numpy.datetime64 reference handling. ### Changed - Minor performance improvements. ## 3.9.5 - 2023-08-16 ### Fixed - Remove futex from module import and initialization path. ## 3.9.4 - 2023-08-07 ### Fixed - Fix hash builder using default values. - Fix non-release builds of orjson copying large deserialization buffer from stack to heap. This was introduced in 3.9.3. ## 3.9.3 - 2023-08-06 ### Fixed - Fix compatibility with CPython 3.12. ### Changed - Support i686/x86 32-bit Python installs on Windows. ## 3.9.2 - 2023-07-07 ### Fixed - Fix the `__cause__` exception on `orjson.JSONEncodeError` possibly being denormalized, i.e., of type `str` instead of `Exception`. ## 3.9.1 - 2023-06-09 ### Fixed - Fix memory leak on chained tracebacks of exceptions raised in `default`. This was introduced in 3.8.12. ## 3.9.0 - 2023-06-01 ### Added - `orjson.Fragment` includes already-serialized JSON in a document. ## 3.8.14 - 2023-05-25 ### Changed - PyPI `manylinux` wheels are compiled for `x86-64` instead of `x86-64-v2`. ## 3.8.13 - 2023-05-23 ### Changed - Source distribution contains all source code required for an offline build. - PyPI macOS wheels use a `MACOSX_DEPLOYMENT_TARGET` of 10.15 instead of 11. - Build uses maturin v1. ## 3.8.12 - 2023-05-07 ### Changed - Exceptions raised in `default` are now chained as the `__cause__` attribute on `orjson.JSONEncodeError`. ## 3.8.11 - 2023-04-27 ### Changed - `orjson.loads()` on an empty document has a specific error message. - PyPI `manylinux_2_28_x86_64` wheels are compiled for `x86-64-v2`. - PyPI macOS wheels are only `universal2` and compiled for `x86-64-v2` and `apple-m1`. ## 3.8.10 - 2023-04-09 ### Fixed - Fix compatibility with CPython 3.12.0a7. - Fix compatibility with big-endian architectures. - Fix crash in serialization. ### Changed - Publish musllinux 3.11 wheels. - Publish s390x wheels. ## 3.8.9 - 2023-03-28 ### Fixed - Fix parallel initialization of orjson. ## 3.8.8 - 2023-03-20 ### Changed - Publish ppc64le wheels. ## 3.8.7 - 2023-02-28 ### Fixed - Use serialization backend introduced in 3.8.4 only on well-tested platforms such as glibc, macOS by default. ## 3.8.6 - 2023-02-09 ### Fixed - Fix crash serializing when using musl libc. ### Changed - Make `python-dateutil` optional in tests. - Handle failure to load system timezones in tests. ## 3.8.5 - 2023-01-10 ### Fixed - Fix `orjson.dumps()` invalid output on Windows. ## 3.8.4 - 2023-01-04 ### Changed - Improve performance. ## 3.8.3 - 2022-12-02 ### Fixed - `orjson.dumps()` accepts `option=None` per `Optional[int]` type. ## 3.8.2 - 2022-11-20 ### Fixed - Fix tests on 32-bit for `numpy.intp` and `numpy.uintp`. ### Changed - Build now depends on rustc 1.60 or later. - Support building with maturin 0.13 or 0.14. ## 3.8.1 - 2022-10-25 ### Changed - Build maintenance for Python 3.11. ## 3.8.0 - 2022-08-27 ### Changed - Support serializing `numpy.int16` and `numpy.uint16`. ## 3.7.12 - 2022-08-14 ### Fixed - Fix datetime regression tests for tzinfo 2022b. ### Changed - Improve performance. ## 3.7.11 - 2022-07-31 ### Fixed - Revert `dict` iterator implementation introduced in 3.7.9. ## 3.7.10 - 2022-07-30 ### Fixed - Fix serializing `dict` with deleted final item. This was introduced in 3.7.9. ## 3.7.9 - 2022-07-29 ### Changed - Improve performance of serializing. - Improve performance of serializing pretty-printed (`orjson.OPT_INDENT_2`) to be much nearer to compact. - Improve performance of deserializing `str` input. - orjson now requires Rust 1.57 instead of 1.54 to build. ## 3.7.8 - 2022-07-19 ### Changed - Build makes best effort instead of requiring "--features". - Build using maturin 0.13. ## 3.7.7 - 2022-07-06 ### Changed - Support Python 3.11. ## 3.7.6 - 2022-07-03 ### Changed - Handle unicode changes in CPython 3.12. - Build PyPI macOS wheels on 10.15 instead of 12 for compatibility. ## 3.7.5 - 2022-06-28 ### Fixed - Fix issue serializing dicts that had keys popped and replaced. This was introduced in 3.7.4. ## 3.7.4 - 2022-06-28 ### Changed - Improve performance. ### Fixed - Fix deallocation of `orjson.JSONDecodeError`. ## 3.7.3 - 2022-06-23 ## Changed - Improve build. - Publish aarch64 musllinux wheels. ## 3.7.2 - 2022-06-07 ## Changed - Improve deserialization performance. ## 3.7.1 - 2022-06-03 ### Fixed - Type stubs for `orjson.JSONDecodeError` now inherit from `json.JSONDecodeError` instead of `ValueError` - Null-terminate the internal buffer of `orjson.dumps()` output. ## 3.7.0 - 2022-06-03 ### Changed - Improve deserialization performance significantly through the use of a new backend. PyPI wheels for manylinux_2_28 and macOS have it enabled. Packagers are advised to see the README. ## 3.6.9 - 2022-06-01 ### Changed - Improve serialization and deserialization performance. ## 3.6.8 - 2022-04-15 ### Fixed - Fix serialization of `numpy.datetime64("NaT")` to raise on an unsupported type. ## 3.6.7 - 2022-02-14 ### Changed - Improve performance of deserializing almost-empty documents. - Publish arm7l `manylinux_2_17` wheels to PyPI. - Publish amd4 `musllinux_1_1` wheels to PyPI. ### Fixed - Fix build requiring `python` on `PATH`. ## 3.6.6 - 2022-01-21 ### Changed - Improve performance of serializing `datetime.datetime` using `tzinfo` that are `zoneinfo.ZoneInfo`. ### Fixed - Fix invalid indexing in line and column number reporting in `JSONDecodeError`. - Fix `orjson.OPT_STRICT_INTEGER` not raising an error on values exceeding a 64-bit integer maximum. ## 3.6.5 - 2021-12-05 ### Fixed - Fix build on macOS aarch64 CPython 3.10. - Fix build issue on 32-bit. ## 3.6.4 - 2021-10-01 ### Fixed - Fix serialization of `dataclass` inheriting from `abc.ABC` and using `__slots__`. - Decrement refcount for numpy `PyArrayInterface`. - Fix build on recent versions of Rust nightly. ## 3.6.3 - 2021-08-20 ### Fixed - Fix build on aarch64 using the Rust stable channel. ## 3.6.2 - 2021-08-17 ### Changed - `orjson` now compiles on Rust stable 1.54.0 or above. Use of some SIMD usage is now disabled by default and packagers are advised to add `--cargo-extra-args="--features=unstable-simd"` to the `maturin build` command if they continue to use nightly. - `orjson` built with `--features=unstable-simd` adds UTF-8 validation implementations that use AVX2 or SSE4.2. - Drop support for Python 3.6. ## 3.6.1 - 2021-08-04 ### Changed - `orjson` now includes a `pyi` type stubs file. - Publish manylinux_2_24 wheels instead of manylinux2014. ### Fixed - Fix compilation on latest Rust nightly. ## 3.6.0 - 2021-07-08 ### Added - `orjson.dumps()` serializes `numpy.datetime64` instances as RFC 3339 strings. ## 3.5.4 - 2021-06-30 ### Fixed - Fix memory leak serializing `datetime.datetime` with `tzinfo`. - Fix wrong error message when serializing an unsupported numpy type without default specified. ### Changed - Publish python3.10 and python3.9 manylinux_2_24 wheels. ## 3.5.3 - 2021-06-01 ### Fixed - `orjson.JSONDecodeError` now has `pos`, `lineno`, and `colno`. - Fix build on recent versions of Rust nightly. ## 3.5.2 - 2021-04-15 ### Changed - Improve serialization and deserialization performance. - `orjson.dumps()` serializes individual `numpy.bool_` objects. ## 3.5.1 - 2021-03-06 ### Changed - Publish `universal2` wheels for macOS supporting Apple Silicon (aarch64). ## 3.5.0 - 2021-02-24 ### Added - `orjson.loads()` supports reading from `memoryview` objects. ### Fixed - `datetime.datetime` and `datetime.date` zero pad years less than 1000 to four digits. - sdist pins maturin 0.9.0 to avoid breaks in later 0.9.x. ### Changed - `orjson.dumps()` when given a non-C contiguous `numpy.ndarray` has an error message suggesting to use `default`. ## 3.4.8 - 2021-02-04 ### Fixed - aarch64 manylinux2014 wheels are now compatible with glibc 2.17. ### Changed - Fix build warnings on ppcle64. ## 3.4.7 - 2021-01-19 ### Changed - Use vectorcall APIs for method calls on python3.9 and above. - Publish python3.10 wheels for Linux on amd64 and aarch64. ## 3.4.6 - 2020-12-07 ### Fixed - Fix compatibility with debug builds of CPython. ## 3.4.5 - 2020-12-02 ### Fixed - Fix deserializing long strings on processors without AVX2. ## 3.4.4 - 2020-11-25 ### Changed - `orjson.dumps()` serializes integers up to a 64-bit unsigned integer's maximum. It was previously the maximum of a 64-bit signed integer. ## 3.4.3 - 2020-10-30 ### Fixed - Fix regression in parsing similar `dict` keys. ## 3.4.2 - 2020-10-29 ### Changed - Improve deserialization performance. - Publish Windows python3.9 wheel. - Disable unsupported SIMD features on non-x86, non-ARM targets ## 3.4.1 - 2020-10-20 ### Fixed - Fix `orjson.dumps.__module__` and `orjson.loads.__module__` not being the `str` "orjson". ### Changed - Publish macos python3.9 wheel. - More packaging documentation. ## 3.4.0 - 2020-09-25 ### Added - Serialize `numpy.uint8` and `numpy.int8` instances. ### Fixed - Fix serializing `numpy.empty()` instances. ### Changed - No longer publish `manylinux1` wheels due to tooling dropping support. ## 3.3.1 - 2020-08-17 ### Fixed - Fix failure to deserialize some latin1 strings on some platforms. This was introduced in 3.2.0. - Fix annotation of optional parameters on `orjson.dumps()` for `help()`. ### Changed - Publish `manylinux2014` wheels for amd64 in addition to `manylinux1`. ## 3.3.0 - 2020-07-24 ### Added - `orjson.dumps()` now serializes individual numpy floats and integers, e.g., `numpy.float64(1.0)`. - `orjson.OPT_PASSTHROUGH_DATACLASS` causes `orjson.dumps()` to pass `dataclasses.dataclass` instances to `default`. ## 3.2.2 - 2020-07-13 ### Fixed - Fix serializing `dataclasses.dataclass` that have no attributes. ### Changed - Improve deserialization performance of `str`. ## 3.2.1 - 2020-07-03 ### Fixed - Fix `orjson.dumps(..., **{})` raising `TypeError` on python3.6. ## 3.2.0 - 2020-06-30 ### Added - `orjson.OPT_APPEND_NEWLINE` appends a newline to output. ### Changed - Improve deserialization performance of `str`. ## 3.1.2 - 2020-06-23 ### Fixed - Fix serializing zero-dimension `numpy.ndarray`. ## 3.1.1 - 2020-06-20 ### Fixed - Fix repeated serialization of `str` that are ASCII-only and have a legacy (non-compact) layout. ## 3.1.0 - 2020-06-08 ### Added - `orjson.OPT_PASSTHROUGH_SUBCLASS` causes `orjson.dumps()` to pass subclasses of builtin types to `default` so the caller can customize the output. - `orjson.OPT_PASSTHROUGH_DATETIME` causes `orjson.dumps()` to pass `datetime` objects to `default` so the caller can customize the output. ## 3.0.2 - 2020-05-27 ### Changed - `orjson.dumps()` does not serialize `dataclasses.dataclass` attributes that begin with a leading underscore, e.g., `_attr`. This is because of the Python idiom that a leading underscores marks an attribute as "private." - `orjson.dumps()` does not serialize `dataclasses.dataclass` attributes that are `InitVar` or `ClassVar` whether using `__slots__` or not. ## 3.0.1 - 2020-05-19 ### Fixed - `orjson.dumps()` raises an exception if the object to be serialized is not given as a positional argument. `orjson.dumps({})` is intended and ok while `orjson.dumps(obj={})` is an error. This makes it consistent with the documentation, `help()` annotation, and type annotation. - Fix orphan reference in exception creation that leaks memory until the garbage collector runs. ### Changed - Improve serialization performance marginally by using the fastcall/vectorcall calling convention on python3.7 and above. - Reduce build time. ## 3.0.0 - 2020-05-01 ### Added - `orjson.dumps()` serializes subclasses of `str`, `int`, `list`, and `dict`. ### Changed - `orjson.dumps()` serializes `dataclasses.dataclass` and `uuid.UUID` instances by default. The options `OPT_SERIALIZE_DATACLASS` and `OPT_SERIALIZE_UUID` can still be specified but have no effect. ## 2.6.8 - 2020-04-30 ### Changed - The source distribution vendors a forked dependency. ## 2.6.7 - 2020-04-30 ### Fixed - Fix integer overflows in debug builds. ### Changed - The source distribution sets the recommended RUSTFLAGS in `.cargo/config`. ## 2.6.6 - 2020-04-24 ### Fixed - Import `numpy` only on first use of `OPT_SERIALIZE_NUMPY` to reduce interpreter start time when not used. - Reduce build time by half. ## 2.6.5 - 2020-04-08 ### Fixed - Fix deserialization raising `JSONDecodeError` on some valid negative floats with large exponents. ## 2.6.4 - 2020-04-08 ### Changed - Improve deserialization performance of floats by about 40%. ## 2.6.3 - 2020-04-01 ### Changed - Serialize `enum.Enum` objects. - Minor performance improvements. ## 2.6.2 - 2020-03-27 ### Changed - Publish python3.9 `manylinux2014` wheel instead of `manylinux1` for `x86_64`. - Publish python3.9 `manylinux2014` wheel for `aarch64`. ### Fixed - Fix compilation failure on 32-bit. ## 2.6.1 - 2020-03-19 ### Changed - Serialization is 10-20% faster and uses about 50% less memory by writing directly to the returned `bytes` object. ## 2.6.0 - 2020-03-10 ### Added - `orjson.dumps()` pretty prints with an indentation of two spaces if `option=orjson.OPT_INDENT_2` is specified. ## 2.5.2 - 2020-03-07 ### Changed - Publish `manylinux2014` wheels for `aarch64`. - numpy support now includes `numpy.uint32` and `numpy.uint64`. ## 2.5.1 - 2020-02-24 ### Changed - `manylinux1` wheels for 3.6, 3.7, and 3.8 are now compliant with the spec by not depending on glibc 2.18. ## 2.5.0 - 2020-02-19 ### Added - `orjson.dumps()` serializes `dict` keys of type other than `str` if `option=orjson.OPT_NON_STR_KEYS` is specified. ## 2.4.0 - 2020-02-14 ### Added - `orjson.dumps()` serializes `numpy.ndarray` instances if `option=orjson.OPT_SERIALIZE_NUMPY` is specified. ### Fixed - Fix `dataclasses.dataclass` attributes that are `dict` to be effected by `orjson.OPT_SORT_KEYS`. ## 2.3.0 - 2020-02-12 ### Added - `orjson.dumps()` serializes `dict` instances sorted by keys, equivalent to `sort_keys` in other implementations, if `option=orjson.OPT_SORT_KEYS` is specified. ### Changed - `dataclasses.dataclass` instances without `__slots__` now serialize faster. ### Fixed - Fix documentation on `default`, in particular documenting the need to raise an exception if the type cannot be handled. ## 2.2.2 - 2020-02-10 ### Changed - Performance improvements to serializing a list containing elements of the same type. ## 2.2.1 - 2020-02-04 ### Fixed - `orjson.loads()` rejects floats that do not have a digit following the decimal, e.g., `-2.`, `2.e-3`. ### Changed - Build Linux, macOS, and Windows wheels on more recent distributions. ## 2.2.0 - 2020-01-22 ### Added - `orjson.dumps()` serializes `uuid.UUID` instances if `option=orjson.OPT_SERIALIZE_UUID` is specified. ### Changed - Minor performance improvements. - Publish Python 3.9 wheel for Linux. ## 2.1.4 - 2020-01-08 ### Fixed - Specify a text signature for `orjson.loads()`. ### Changed - Improve documentation. ## 2.1.3 - 2019-11-12 ### Changed - Publish Python 3.8 wheels for macOS and Windows. ## 2.1.2 - 2019-11-07 ### Changed - The recursion limit of `default` on `orjson.dumps()` has been increased from 5 to 254. ## 2.1.1 - 2019-10-29 ### Changed - Publish `manylinux1` wheels instead of `manylinux2010`. ## 2.1.0 - 2019-10-24 ### Added - `orjson.dumps()` serializes `dataclasses.dataclass` instances if `option=orjson.OPT_SERIALIZE_DATACLASS` is specified. - `orjson.dumps()` accepts `orjson.OPT_UTC_Z` to serialize UTC as "Z" instead of "+00:00". - `orjson.dumps()` accepts `orjson.OPT_OMIT_MICROSECONDS` to not serialize the `microseconds` attribute of `datetime.datetime` and `datetime.time` instances. - `orjson.loads()` accepts `bytearray`. ### Changed - Drop support for Python 3.5. - Publish `manylinux2010` wheels instead of `manylinux1`. ## 2.0.11 - 2019-10-01 ### Changed - Publish Python 3.8 wheel for Linux. ## 2.0.10 - 2019-09-25 ### Changed - Performance improvements and lower memory usage in deserialization by creating only one `str` object for repeated map keys. ## 2.0.9 - 2019-09-22 ### Changed - Minor performance improvements. ### Fixed - Fix inaccurate zero padding in serialization of microseconds on `datetime.time` objects. ## 2.0.8 - 2019-09-18 ### Fixed - Fix inaccurate zero padding in serialization of microseconds on `datetime.datetime` objects. ## 2.0.7 - 2019-08-29 ### Changed - Publish PEP 517 source distribution. ### Fixed - `orjson.dumps()` raises `JSONEncodeError` on circular references. ## 2.0.6 - 2019-05-11 ### Changed - Performance improvements. ## 2.0.5 - 2019-04-19 ### Fixed - Fix inaccuracy in deserializing some `float` values, e.g., 31.245270191439438 was parsed to 31.24527019143944. Serialization was unaffected. ## 2.0.4 - 2019-04-02 ### Changed - `orjson.dumps()` now serializes `datetime.datetime` objects without a `tzinfo` rather than raising `JSONEncodeError`. ## 2.0.3 - 2019-03-23 ### Changed - `orjson.loads()` uses SSE2 to validate `bytes` input. ## 2.0.2 - 2019-03-12 ### Changed - Support Python 3.5. ## 2.0.1 - 2019-02-05 ### Changed - Publish Windows wheel. ## 2.0.0 - 2019-01-28 ### Added - `orjson.dumps()` accepts a `default` callable to serialize arbitrary types. - `orjson.dumps()` accepts `datetime.datetime`, `datetime.date`, and `datetime.time`. Each is serialized to an RFC 3339 string. - `orjson.dumps(..., option=orjson.OPT_NAIVE_UTC)` allows serializing `datetime.datetime` objects that do not have a timezone set as UTC. - `orjson.dumps(..., option=orjson.OPT_STRICT_INTEGER)` available to raise an error on integer values outside the 53-bit range of all JSON implementations. ### Changed - `orjson.dumps()` no longer accepts `bytes`. ## 1.3.1 - 2019-01-03 ### Fixed - Handle invalid UTF-8 in str. ## 1.3.0 - 2019-01-02 ### Changed - Performance improvements of 15-25% on serialization, 10% on deserialization. ## 1.2.1 - 2018-12-31 ### Fixed - Fix memory leak in deserializing dict. ## 1.2.0 - 2018-12-16 ### Changed - Performance improvements. ## 1.1.0 - 2018-12-04 ### Changed - Performance improvements. ### Fixed - Dict key can only be str. ## 1.0.1 - 2018-11-26 ### Fixed - pyo3 bugfix update. ## 1.0.0 - 2018-11-23 ### Added - `orjson.dumps()` function. - `orjson.loads()` function. orjson-3.9.15/CONTRIBUTING.md000066400000000000000000000003001456615046100153550ustar00rootroot00000000000000orjson is stable. Contributions will be reviewed only if they are well documented, tested to the same standard as the rest of the library, not a breaking change, and important to other users. orjson-3.9.15/Cargo.lock000066400000000000000000000230011456615046100150340ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "ahash" version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if", "const-random", "once_cell", "version_check", "zerocopy", ] [[package]] name = "arrayvec" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" dependencies = [ "serde", ] [[package]] name = "associative-cache" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b993cd767a2bc7307dd87622311ca22c44329cc7a21366206bfa0896827b2bad" [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "beef" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" dependencies = [ "serde", ] [[package]] name = "bytecount" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "castaway" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" dependencies = [ "rustversion", ] [[package]] name = "cc" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "num-traits", ] [[package]] name = "compact_str" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" dependencies = [ "castaway", "cfg-if", "itoa", "ryu", "serde", "static_assertions", ] [[package]] name = "const-random" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" dependencies = [ "const-random-macro", ] [[package]] name = "const-random-macro" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ "getrandom", "once_cell", "tiny-keccak", ] [[package]] name = "crunchy" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "encoding_rs" version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] [[package]] name = "getrandom" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "itoa" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" dependencies = [ "no-panic", ] [[package]] name = "itoap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "no-panic" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c711522eedec2a96bb3672ad60a03561cb28934ab1e9b97d2ecb58e07c79ef52" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "num-traits" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "orjson" version = "3.9.15" dependencies = [ "ahash", "arrayvec", "associative-cache", "beef", "bytecount", "cc", "chrono", "compact_str", "encoding_rs", "itoa", "itoap", "once_cell", "pyo3-build-config", "pyo3-ffi", "ryu", "serde", "serde_json", "simdutf8", "smallvec", "version_check", ] [[package]] name = "proc-macro2" version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3-build-config" version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07426f0d8fe5a601f26293f300afd1a7b1ed5e78b2a705870c5f30893c5163be" dependencies = [ "once_cell", "target-lexicon", ] [[package]] name = "pyo3-ffi" version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb7dec17e17766b46bca4f1a4215a85006b4c2ecde122076c562dd058da6cf1" dependencies = [ "libc", "pyo3-build-config", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "rustversion" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" dependencies = [ "no-panic", ] [[package]] name = "serde" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", "serde", ] [[package]] name = "simdutf8" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "target-lexicon" version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tiny-keccak" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" dependencies = [ "crunchy", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "zerocopy" version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", "syn", ] orjson-3.9.15/Cargo.toml000066400000000000000000000053001456615046100150610ustar00rootroot00000000000000[package] name = "orjson" version = "3.9.15" authors = ["ijl "] description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" edition = "2021" resolver = "2" rust-version = "1.72" license = "Apache-2.0 OR MIT" repository = "https://github.com/ijl/orjson" homepage = "https://github.com/ijl/orjson" readme = "README.md" keywords = ["fast", "json", "dataclass", "dataclasses", "datetime", "rfc", "8259", "3339"] include = [ "Cargo.toml", "CHANGELOG.md", "data", "include", "LICENSE-APACHE", "LICENSE-MIT", "pyproject.toml", "README.md", "src", "test/*.py", "test/requirements.txt", ] [lib] name = "orjson" crate-type = ["cdylib"] [features] default = [] # Use SIMD intrinsics. This requires Rust on the nightly channel. unstable-simd = [] no-panic = [ "itoa/no-panic", "ryu/no-panic", ] # Build yyjson as a backend and panic if it fails. The default is to attempt # to build and on failure fall back to another backend. yyjson = [] [dependencies] ahash = { version = "^0.8.9", default_features = false, features = ["compile-time-rng"] } arrayvec = { version = "0.7", default_features = false, features = ["std", "serde"] } associative-cache = { version = "2", default_features = false } beef = { version = "0.5", default_features = false, features = ["impl_serde"] } bytecount = { version = "^0.6.7", default_features = false, features = ["runtime-dispatch-simd"] } chrono = { version = "^0.4.31", default_features = false } compact_str = { version = "0.7", default_features = false, features = ["serde"] } encoding_rs = { version = "0.8", default_features = false } itoa = { version = "1", default_features = false } itoap = { version = "1", features = ["std", "simd"] } once_cell = { version = "1", default_features = false, features = ["race"] } pyo3-ffi = { version = "^0.20.2", default_features = false, features = ["extension-module"]} ryu = { version = "1", default_features = false } serde = { version = "1", default_features = false } serde_json = { version = "1", default_features = false, features = ["std", "float_roundtrip"] } simdutf8 = { version = "0.1", default_features = false, features = ["std", "aarch64_neon"] } smallvec = { version = "^1.11", default_features = false, features = ["union", "write"] } [build-dependencies] cc = { version = "1" } pyo3-build-config = { version = "^0.20.2" } version_check = { version = "0.9" } [profile.dev] codegen-units = 1 debug = 2 debug-assertions = true incremental = false lto = "off" opt-level = 3 overflow-checks = true [profile.release] codegen-units = 1 debug = false incremental = false lto = "thin" opt-level = 3 panic = "abort" [profile.release.build-override] opt-level = 0 orjson-3.9.15/LICENSE-APACHE000066400000000000000000000251371456615046100150670ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. orjson-3.9.15/LICENSE-MIT000066400000000000000000000017771456615046100146030ustar00rootroot00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. orjson-3.9.15/README.md000066400000000000000000001356201456615046100144210ustar00rootroot00000000000000# orjson orjson is a fast, correct JSON library for Python. It [benchmarks](https://github.com/ijl/orjson#performance) as the fastest Python library for JSON and is more correct than the standard json library or other third-party libraries. It serializes [dataclass](https://github.com/ijl/orjson#dataclass), [datetime](https://github.com/ijl/orjson#datetime), [numpy](https://github.com/ijl/orjson#numpy), and [UUID](https://github.com/ijl/orjson#uuid) instances natively. Its features and drawbacks compared to other Python JSON libraries: * serializes `dataclass` instances 40-50x as fast as other libraries * serializes `datetime`, `date`, and `time` instances to RFC 3339 format, e.g., "1970-01-01T00:00:00+00:00" * serializes `numpy.ndarray` instances 4-12x as fast with 0.3x the memory usage of other libraries * pretty prints 10x to 20x as fast as the standard library * serializes to `bytes` rather than `str`, i.e., is not a drop-in replacement * serializes `str` without escaping unicode to ASCII, e.g., "好" rather than "\\\u597d" * serializes `float` 10x as fast and deserializes twice as fast as other libraries * serializes subclasses of `str`, `int`, `list`, and `dict` natively, requiring `default` to specify how to serialize others * serializes arbitrary types using a `default` hook * has strict UTF-8 conformance, more correct than the standard library * has strict JSON conformance in not supporting Nan/Infinity/-Infinity * has an option for strict JSON conformance on 53-bit integers with default support for 64-bit * does not provide `load()` or `dump()` functions for reading from/writing to file-like objects orjson supports CPython 3.8, 3.9, 3.10, 3.11, and 3.12. It distributes amd64/x86_64, aarch64/armv8, arm7, POWER/ppc64le, and s390x wheels for Linux, amd64 and aarch64 wheels for macOS, and amd64 and i686/x86 wheels for Windows. orjson does not and will not support PyPy. orjson does not and will not support PEP 554 subinterpreters. Releases follow semantic versioning and serializing a new object type without an opt-in flag is considered a breaking change. orjson is licensed under both the Apache 2.0 and MIT licenses. The repository and issue tracker is [github.com/ijl/orjson](https://github.com/ijl/orjson), and patches may be submitted there. There is a [CHANGELOG](https://github.com/ijl/orjson/blob/master/CHANGELOG.md) available in the repository. 1. [Usage](https://github.com/ijl/orjson#usage) 1. [Install](https://github.com/ijl/orjson#install) 2. [Quickstart](https://github.com/ijl/orjson#quickstart) 3. [Migrating](https://github.com/ijl/orjson#migrating) 4. [Serialize](https://github.com/ijl/orjson#serialize) 1. [default](https://github.com/ijl/orjson#default) 2. [option](https://github.com/ijl/orjson#option) 3. [Fragment](https://github.com/ijl/orjson#fragment) 5. [Deserialize](https://github.com/ijl/orjson#deserialize) 2. [Types](https://github.com/ijl/orjson#types) 1. [dataclass](https://github.com/ijl/orjson#dataclass) 2. [datetime](https://github.com/ijl/orjson#datetime) 3. [enum](https://github.com/ijl/orjson#enum) 4. [float](https://github.com/ijl/orjson#float) 5. [int](https://github.com/ijl/orjson#int) 6. [numpy](https://github.com/ijl/orjson#numpy) 7. [str](https://github.com/ijl/orjson#str) 8. [uuid](https://github.com/ijl/orjson#uuid) 3. [Testing](https://github.com/ijl/orjson#testing) 4. [Performance](https://github.com/ijl/orjson#performance) 1. [Latency](https://github.com/ijl/orjson#latency) 2. [Memory](https://github.com/ijl/orjson#memory) 3. [Reproducing](https://github.com/ijl/orjson#reproducing) 5. [Questions](https://github.com/ijl/orjson#questions) 6. [Packaging](https://github.com/ijl/orjson#packaging) 7. [License](https://github.com/ijl/orjson#license) ## Usage ### Install To install a wheel from PyPI: ```sh pip install --upgrade "pip>=20.3" # manylinux_x_y, universal2 wheel support pip install --upgrade orjson ``` To build a wheel, see [packaging](https://github.com/ijl/orjson#packaging). ### Quickstart This is an example of serializing, with options specified, and deserializing: ```python >>> import orjson, datetime, numpy >>> data = { "type": "job", "created_at": datetime.datetime(1970, 1, 1), "status": "🆗", "payload": numpy.array([[1, 2], [3, 4]]), } >>> orjson.dumps(data, option=orjson.OPT_NAIVE_UTC | orjson.OPT_SERIALIZE_NUMPY) b'{"type":"job","created_at":"1970-01-01T00:00:00+00:00","status":"\xf0\x9f\x86\x97","payload":[[1,2],[3,4]]}' >>> orjson.loads(_) {'type': 'job', 'created_at': '1970-01-01T00:00:00+00:00', 'status': '🆗', 'payload': [[1, 2], [3, 4]]} ``` ### Migrating orjson version 3 serializes more types than version 2. Subclasses of `str`, `int`, `dict`, and `list` are now serialized. This is faster and more similar to the standard library. It can be disabled with `orjson.OPT_PASSTHROUGH_SUBCLASS`.`dataclasses.dataclass` instances are now serialized by default and cannot be customized in a `default` function unless `option=orjson.OPT_PASSTHROUGH_DATACLASS` is specified. `uuid.UUID` instances are serialized by default. For any type that is now serialized, implementations in a `default` function and options enabling them can be removed but do not need to be. There was no change in deserialization. To migrate from the standard library, the largest difference is that `orjson.dumps` returns `bytes` and `json.dumps` returns a `str`. Users with `dict` objects using non-`str` keys should specify `option=orjson.OPT_NON_STR_KEYS`. `sort_keys` is replaced by `option=orjson.OPT_SORT_KEYS`. `indent` is replaced by `option=orjson.OPT_INDENT_2` and other levels of indentation are not supported. ### Serialize ```python def dumps( __obj: Any, default: Optional[Callable[[Any], Any]] = ..., option: Optional[int] = ..., ) -> bytes: ... ``` `dumps()` serializes Python objects to JSON. It natively serializes `str`, `dict`, `list`, `tuple`, `int`, `float`, `bool`, `None`, `dataclasses.dataclass`, `typing.TypedDict`, `datetime.datetime`, `datetime.date`, `datetime.time`, `uuid.UUID`, `numpy.ndarray`, and `orjson.Fragment` instances. It supports arbitrary types through `default`. It serializes subclasses of `str`, `int`, `dict`, `list`, `dataclasses.dataclass`, and `enum.Enum`. It does not serialize subclasses of `tuple` to avoid serializing `namedtuple` objects as arrays. To avoid serializing subclasses, specify the option `orjson.OPT_PASSTHROUGH_SUBCLASS`. The output is a `bytes` object containing UTF-8. The global interpreter lock (GIL) is held for the duration of the call. It raises `JSONEncodeError` on an unsupported type. This exception message describes the invalid object with the error message `Type is not JSON serializable: ...`. To fix this, specify [default](https://github.com/ijl/orjson#default). It raises `JSONEncodeError` on a `str` that contains invalid UTF-8. It raises `JSONEncodeError` on an integer that exceeds 64 bits by default or, with `OPT_STRICT_INTEGER`, 53 bits. It raises `JSONEncodeError` if a `dict` has a key of a type other than `str`, unless `OPT_NON_STR_KEYS` is specified. It raises `JSONEncodeError` if the output of `default` recurses to handling by `default` more than 254 levels deep. It raises `JSONEncodeError` on circular references. It raises `JSONEncodeError` if a `tzinfo` on a datetime object is unsupported. `JSONEncodeError` is a subclass of `TypeError`. This is for compatibility with the standard library. If the failure was caused by an exception in `default` then `JSONEncodeError` chains the original exception as `__cause__`. #### default To serialize a subclass or arbitrary types, specify `default` as a callable that returns a supported type. `default` may be a function, lambda, or callable class instance. To specify that a type was not handled by `default`, raise an exception such as `TypeError`. ```python >>> import orjson, decimal >>> def default(obj): if isinstance(obj, decimal.Decimal): return str(obj) raise TypeError >>> orjson.dumps(decimal.Decimal("0.0842389659712649442845")) JSONEncodeError: Type is not JSON serializable: decimal.Decimal >>> orjson.dumps(decimal.Decimal("0.0842389659712649442845"), default=default) b'"0.0842389659712649442845"' >>> orjson.dumps({1, 2}, default=default) orjson.JSONEncodeError: Type is not JSON serializable: set ``` The `default` callable may return an object that itself must be handled by `default` up to 254 times before an exception is raised. It is important that `default` raise an exception if a type cannot be handled. Python otherwise implicitly returns `None`, which appears to the caller like a legitimate value and is serialized: ```python >>> import orjson, json, rapidjson >>> def default(obj): if isinstance(obj, decimal.Decimal): return str(obj) >>> orjson.dumps({"set":{1, 2}}, default=default) b'{"set":null}' >>> json.dumps({"set":{1, 2}}, default=default) '{"set":null}' >>> rapidjson.dumps({"set":{1, 2}}, default=default) '{"set":null}' ``` #### option To modify how data is serialized, specify `option`. Each `option` is an integer constant in `orjson`. To specify multiple options, mask them together, e.g., `option=orjson.OPT_STRICT_INTEGER | orjson.OPT_NAIVE_UTC`. ##### OPT_APPEND_NEWLINE Append `\n` to the output. This is a convenience and optimization for the pattern of `dumps(...) + "\n"`. `bytes` objects are immutable and this pattern copies the original contents. ```python >>> import orjson >>> orjson.dumps([]) b"[]" >>> orjson.dumps([], option=orjson.OPT_APPEND_NEWLINE) b"[]\n" ``` ##### OPT_INDENT_2 Pretty-print output with an indent of two spaces. This is equivalent to `indent=2` in the standard library. Pretty printing is slower and the output larger. orjson is the fastest compared library at pretty printing and has much less of a slowdown to pretty print than the standard library does. This option is compatible with all other options. ```python >>> import orjson >>> orjson.dumps({"a": "b", "c": {"d": True}, "e": [1, 2]}) b'{"a":"b","c":{"d":true},"e":[1,2]}' >>> orjson.dumps( {"a": "b", "c": {"d": True}, "e": [1, 2]}, option=orjson.OPT_INDENT_2 ) b'{\n "a": "b",\n "c": {\n "d": true\n },\n "e": [\n 1,\n 2\n ]\n}' ``` If displayed, the indentation and linebreaks appear like this: ```json { "a": "b", "c": { "d": true }, "e": [ 1, 2 ] } ``` This measures serializing the github.json fixture as compact (52KiB) or pretty (64KiB): | Library | compact (ms) | pretty (ms) | vs. orjson | |------------|----------------|---------------|--------------| | orjson | 0.03 | 0.04 | 1 | | ujson | 0.18 | 0.19 | 4.6 | | rapidjson | 0.1 | 0.12 | 2.9 | | simplejson | 0.25 | 0.89 | 21.4 | | json | 0.18 | 0.71 | 17 | This measures serializing the citm_catalog.json fixture, more of a worst case due to the amount of nesting and newlines, as compact (489KiB) or pretty (1.1MiB): | Library | compact (ms) | pretty (ms) | vs. orjson | |------------|----------------|---------------|--------------| | orjson | 0.59 | 0.71 | 1 | | ujson | 2.9 | 3.59 | 5 | | rapidjson | 1.81 | 2.8 | 3.9 | | simplejson | 10.43 | 42.13 | 59.1 | | json | 4.16 | 33.42 | 46.9 | This can be reproduced using the `pyindent` script. ##### OPT_NAIVE_UTC Serialize `datetime.datetime` objects without a `tzinfo` as UTC. This has no effect on `datetime.datetime` objects that have `tzinfo` set. ```python >>> import orjson, datetime >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0), ) b'"1970-01-01T00:00:00"' >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0), option=orjson.OPT_NAIVE_UTC, ) b'"1970-01-01T00:00:00+00:00"' ``` ##### OPT_NON_STR_KEYS Serialize `dict` keys of type other than `str`. This allows `dict` keys to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`, `datetime.date`, `datetime.time`, `enum.Enum`, and `uuid.UUID`. For comparison, the standard library serializes `str`, `int`, `float`, `bool` or `None` by default. orjson benchmarks as being faster at serializing non-`str` keys than other libraries. This option is slower for `str` keys than the default. ```python >>> import orjson, datetime, uuid >>> orjson.dumps( {uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"): [1, 2, 3]}, option=orjson.OPT_NON_STR_KEYS, ) b'{"7202d115-7ff3-4c81-a7c1-2a1f067b1ece":[1,2,3]}' >>> orjson.dumps( {datetime.datetime(1970, 1, 1, 0, 0, 0): [1, 2, 3]}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_NAIVE_UTC, ) b'{"1970-01-01T00:00:00+00:00":[1,2,3]}' ``` These types are generally serialized how they would be as values, e.g., `datetime.datetime` is still an RFC 3339 string and respects options affecting it. The exception is that `int` serialization does not respect `OPT_STRICT_INTEGER`. This option has the risk of creating duplicate keys. This is because non-`str` objects may serialize to the same `str` as an existing key, e.g., `{"1": true, 1: false}`. The last key to be inserted to the `dict` will be serialized last and a JSON deserializer will presumably take the last occurrence of a key (in the above, `false`). The first value will be lost. This option is compatible with `orjson.OPT_SORT_KEYS`. If sorting is used, note the sort is unstable and will be unpredictable for duplicate keys. ```python >>> import orjson, datetime >>> orjson.dumps( {"other": 1, datetime.date(1970, 1, 5): 2, datetime.date(1970, 1, 3): 3}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS ) b'{"1970-01-03":3,"1970-01-05":2,"other":1}' ``` This measures serializing 589KiB of JSON comprising a `list` of 100 `dict` in which each `dict` has both 365 randomly-sorted `int` keys representing epoch timestamps as well as one `str` key and the value for each key is a single integer. In "str keys", the keys were converted to `str` before serialization, and orjson still specifes `option=orjson.OPT_NON_STR_KEYS` (which is always somewhat slower). | Library | str keys (ms) | int keys (ms) | int keys sorted (ms) | |------------|-----------------|-----------------|------------------------| | orjson | 1.53 | 2.16 | 4.29 | | ujson | 3.07 | 5.65 | | | rapidjson | 4.29 | | | | simplejson | 11.24 | 14.50 | 21.86 | | json | 7.17 | 8.49 | | ujson is blank for sorting because it segfaults. json is blank because it raises `TypeError` on attempting to sort before converting all keys to `str`. rapidjson is blank because it does not support non-`str` keys. This can be reproduced using the `pynonstr` script. ##### OPT_OMIT_MICROSECONDS Do not serialize the `microsecond` field on `datetime.datetime` and `datetime.time` instances. ```python >>> import orjson, datetime >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0, 1), ) b'"1970-01-01T00:00:00.000001"' >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0, 1), option=orjson.OPT_OMIT_MICROSECONDS, ) b'"1970-01-01T00:00:00"' ``` ##### OPT_PASSTHROUGH_DATACLASS Passthrough `dataclasses.dataclass` instances to `default`. This allows customizing their output but is much slower. ```python >>> import orjson, dataclasses >>> @dataclasses.dataclass class User: id: str name: str password: str def default(obj): if isinstance(obj, User): return {"id": obj.id, "name": obj.name} raise TypeError >>> orjson.dumps(User("3b1", "asd", "zxc")) b'{"id":"3b1","name":"asd","password":"zxc"}' >>> orjson.dumps(User("3b1", "asd", "zxc"), option=orjson.OPT_PASSTHROUGH_DATACLASS) TypeError: Type is not JSON serializable: User >>> orjson.dumps( User("3b1", "asd", "zxc"), option=orjson.OPT_PASSTHROUGH_DATACLASS, default=default, ) b'{"id":"3b1","name":"asd"}' ``` ##### OPT_PASSTHROUGH_DATETIME Passthrough `datetime.datetime`, `datetime.date`, and `datetime.time` instances to `default`. This allows serializing datetimes to a custom format, e.g., HTTP dates: ```python >>> import orjson, datetime >>> def default(obj): if isinstance(obj, datetime.datetime): return obj.strftime("%a, %d %b %Y %H:%M:%S GMT") raise TypeError >>> orjson.dumps({"created_at": datetime.datetime(1970, 1, 1)}) b'{"created_at":"1970-01-01T00:00:00"}' >>> orjson.dumps({"created_at": datetime.datetime(1970, 1, 1)}, option=orjson.OPT_PASSTHROUGH_DATETIME) TypeError: Type is not JSON serializable: datetime.datetime >>> orjson.dumps( {"created_at": datetime.datetime(1970, 1, 1)}, option=orjson.OPT_PASSTHROUGH_DATETIME, default=default, ) b'{"created_at":"Thu, 01 Jan 1970 00:00:00 GMT"}' ``` This does not affect datetimes in `dict` keys if using OPT_NON_STR_KEYS. ##### OPT_PASSTHROUGH_SUBCLASS Passthrough subclasses of builtin types to `default`. ```python >>> import orjson >>> class Secret(str): pass def default(obj): if isinstance(obj, Secret): return "******" raise TypeError >>> orjson.dumps(Secret("zxc")) b'"zxc"' >>> orjson.dumps(Secret("zxc"), option=orjson.OPT_PASSTHROUGH_SUBCLASS) TypeError: Type is not JSON serializable: Secret >>> orjson.dumps(Secret("zxc"), option=orjson.OPT_PASSTHROUGH_SUBCLASS, default=default) b'"******"' ``` This does not affect serializing subclasses as `dict` keys if using OPT_NON_STR_KEYS. ##### OPT_SERIALIZE_DATACLASS This is deprecated and has no effect in version 3. In version 2 this was required to serialize `dataclasses.dataclass` instances. For more, see [dataclass](https://github.com/ijl/orjson#dataclass). ##### OPT_SERIALIZE_NUMPY Serialize `numpy.ndarray` instances. For more, see [numpy](https://github.com/ijl/orjson#numpy). ##### OPT_SERIALIZE_UUID This is deprecated and has no effect in version 3. In version 2 this was required to serialize `uuid.UUID` instances. For more, see [UUID](https://github.com/ijl/orjson#UUID). ##### OPT_SORT_KEYS Serialize `dict` keys in sorted order. The default is to serialize in an unspecified order. This is equivalent to `sort_keys=True` in the standard library. This can be used to ensure the order is deterministic for hashing or tests. It has a substantial performance penalty and is not recommended in general. ```python >>> import orjson >>> orjson.dumps({"b": 1, "c": 2, "a": 3}) b'{"b":1,"c":2,"a":3}' >>> orjson.dumps({"b": 1, "c": 2, "a": 3}, option=orjson.OPT_SORT_KEYS) b'{"a":3,"b":1,"c":2}' ``` This measures serializing the twitter.json fixture unsorted and sorted: | Library | unsorted (ms) | sorted (ms) | vs. orjson | |------------|-----------------|---------------|--------------| | orjson | 0.32 | 0.54 | 1 | | ujson | 1.6 | 2.07 | 3.8 | | rapidjson | 1.12 | 1.65 | 3.1 | | simplejson | 2.25 | 3.13 | 5.8 | | json | 1.78 | 2.32 | 4.3 | The benchmark can be reproduced using the `pysort` script. The sorting is not collation/locale-aware: ```python >>> import orjson >>> orjson.dumps({"a": 1, "ä": 2, "A": 3}, option=orjson.OPT_SORT_KEYS) b'{"A":3,"a":1,"\xc3\xa4":2}' ``` This is the same sorting behavior as the standard library, rapidjson, simplejson, and ujson. `dataclass` also serialize as maps but this has no effect on them. ##### OPT_STRICT_INTEGER Enforce 53-bit limit on integers. The limit is otherwise 64 bits, the same as the Python standard library. For more, see [int](https://github.com/ijl/orjson#int). ##### OPT_UTC_Z Serialize a UTC timezone on `datetime.datetime` instances as `Z` instead of `+00:00`. ```python >>> import orjson, datetime, zoneinfo >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo("UTC")), ) b'"1970-01-01T00:00:00+00:00"' >>> orjson.dumps( datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo("UTC")), option=orjson.OPT_UTC_Z ) b'"1970-01-01T00:00:00Z"' ``` #### Fragment `orjson.Fragment` includes already-serialized JSON in a document. This is an efficient way to include JSON blobs from a cache, JSONB field, or separately serialized object without first deserializing to Python objects via `loads()`. ```python >>> import orjson >>> orjson.dumps({"key": "zxc", "data": orjson.Fragment(b'{"a": "b", "c": 1}')}) b'{"key":"zxc","data":{"a": "b", "c": 1}}' ``` It does no reformatting: `orjson.OPT_INDENT_2` will not affect a compact blob nor will a pretty-printed JSON blob be rewritten as compact. The input must be `bytes` or `str` and given as a positional argument. This raises `orjson.JSONEncodeError` if a `str` is given and the input is not valid UTF-8. It otherwise does no validation and it is possible to write invalid JSON. This does not escape characters. The implementation is tested to not crash if given invalid strings or invalid JSON. This is similar to `RawJSON` in rapidjson. ### Deserialize ```python def loads(__obj: Union[bytes, bytearray, memoryview, str]) -> Any: ... ``` `loads()` deserializes JSON to Python objects. It deserializes to `dict`, `list`, `int`, `float`, `str`, `bool`, and `None` objects. `bytes`, `bytearray`, `memoryview`, and `str` input are accepted. If the input exists as a `memoryview`, `bytearray`, or `bytes` object, it is recommended to pass these directly rather than creating an unnecessary `str` object. That is, `orjson.loads(b"{}")` instead of `orjson.loads(b"{}".decode("utf-8"))`. This has lower memory usage and lower latency. The input must be valid UTF-8. orjson maintains a cache of map keys for the duration of the process. This causes a net reduction in memory usage by avoiding duplicate strings. The keys must be at most 64 bytes to be cached and 1024 entries are stored. The global interpreter lock (GIL) is held for the duration of the call. It raises `JSONDecodeError` if given an invalid type or invalid JSON. This includes if the input contains `NaN`, `Infinity`, or `-Infinity`, which the standard library allows, but is not valid JSON. It raises `JSONDecodeError` if a combination of array or object recurses 1024 levels deep. `JSONDecodeError` is a subclass of `json.JSONDecodeError` and `ValueError`. This is for compatibility with the standard library. ## Types ### dataclass orjson serializes instances of `dataclasses.dataclass` natively. It serializes instances 40-50x as fast as other libraries and avoids a severe slowdown seen in other libraries compared to serializing `dict`. It is supported to pass all variants of dataclasses, including dataclasses using `__slots__`, frozen dataclasses, those with optional or default attributes, and subclasses. There is a performance benefit to not using `__slots__`. | Library | dict (ms) | dataclass (ms) | vs. orjson | |------------|-------------|------------------|--------------| | orjson | 1.40 | 1.60 | 1 | | ujson | | | | | rapidjson | 3.64 | 68.48 | 42 | | simplejson | 14.21 | 92.18 | 57 | | json | 13.28 | 94.90 | 59 | This measures serializing 555KiB of JSON, orjson natively and other libraries using `default` to serialize the output of `dataclasses.asdict()`. This can be reproduced using the `pydataclass` script. Dataclasses are serialized as maps, with every attribute serialized and in the order given on class definition: ```python >>> import dataclasses, orjson, typing @dataclasses.dataclass class Member: id: int active: bool = dataclasses.field(default=False) @dataclasses.dataclass class Object: id: int name: str members: typing.List[Member] >>> orjson.dumps(Object(1, "a", [Member(1, True), Member(2)])) b'{"id":1,"name":"a","members":[{"id":1,"active":true},{"id":2,"active":false}]}' ``` ### datetime orjson serializes `datetime.datetime` objects to [RFC 3339](https://tools.ietf.org/html/rfc3339) format, e.g., "1970-01-01T00:00:00+00:00". This is a subset of ISO 8601 and is compatible with `isoformat()` in the standard library. ```python >>> import orjson, datetime, zoneinfo >>> orjson.dumps( datetime.datetime(2018, 12, 1, 2, 3, 4, 9, tzinfo=zoneinfo.ZoneInfo("Australia/Adelaide")) ) b'"2018-12-01T02:03:04.000009+10:30"' >>> orjson.dumps( datetime.datetime(2100, 9, 1, 21, 55, 2).replace(tzinfo=zoneinfo.ZoneInfo("UTC")) ) b'"2100-09-01T21:55:02+00:00"' >>> orjson.dumps( datetime.datetime(2100, 9, 1, 21, 55, 2) ) b'"2100-09-01T21:55:02"' ``` `datetime.datetime` supports instances with a `tzinfo` that is `None`, `datetime.timezone.utc`, a timezone instance from the python3.9+ `zoneinfo` module, or a timezone instance from the third-party `pendulum`, `pytz`, or `dateutil`/`arrow` libraries. It is fastest to use the standard library's `zoneinfo.ZoneInfo` for timezones. `datetime.time` objects must not have a `tzinfo`. ```python >>> import orjson, datetime >>> orjson.dumps(datetime.time(12, 0, 15, 290)) b'"12:00:15.000290"' ``` `datetime.date` objects will always serialize. ```python >>> import orjson, datetime >>> orjson.dumps(datetime.date(1900, 1, 2)) b'"1900-01-02"' ``` Errors with `tzinfo` result in `JSONEncodeError` being raised. To disable serialization of `datetime` objects specify the option `orjson.OPT_PASSTHROUGH_DATETIME`. To use "Z" suffix instead of "+00:00" to indicate UTC ("Zulu") time, use the option `orjson.OPT_UTC_Z`. To assume datetimes without timezone are UTC, use the option `orjson.OPT_NAIVE_UTC`. ### enum orjson serializes enums natively. Options apply to their values. ```python >>> import enum, datetime, orjson >>> class DatetimeEnum(enum.Enum): EPOCH = datetime.datetime(1970, 1, 1, 0, 0, 0) >>> orjson.dumps(DatetimeEnum.EPOCH) b'"1970-01-01T00:00:00"' >>> orjson.dumps(DatetimeEnum.EPOCH, option=orjson.OPT_NAIVE_UTC) b'"1970-01-01T00:00:00+00:00"' ``` Enums with members that are not supported types can be serialized using `default`: ```python >>> import enum, orjson >>> class Custom: def __init__(self, val): self.val = val def default(obj): if isinstance(obj, Custom): return obj.val raise TypeError class CustomEnum(enum.Enum): ONE = Custom(1) >>> orjson.dumps(CustomEnum.ONE, default=default) b'1' ``` ### float orjson serializes and deserializes double precision floats with no loss of precision and consistent rounding. `orjson.dumps()` serializes Nan, Infinity, and -Infinity, which are not compliant JSON, as `null`: ```python >>> import orjson, ujson, rapidjson, json >>> orjson.dumps([float("NaN"), float("Infinity"), float("-Infinity")]) b'[null,null,null]' >>> ujson.dumps([float("NaN"), float("Infinity"), float("-Infinity")]) OverflowError: Invalid Inf value when encoding double >>> rapidjson.dumps([float("NaN"), float("Infinity"), float("-Infinity")]) '[NaN,Infinity,-Infinity]' >>> json.dumps([float("NaN"), float("Infinity"), float("-Infinity")]) '[NaN, Infinity, -Infinity]' ``` ### int orjson serializes and deserializes 64-bit integers by default. The range supported is a signed 64-bit integer's minimum (-9223372036854775807) to an unsigned 64-bit integer's maximum (18446744073709551615). This is widely compatible, but there are implementations that only support 53-bits for integers, e.g., web browsers. For those implementations, `dumps()` can be configured to raise a `JSONEncodeError` on values exceeding the 53-bit range. ```python >>> import orjson >>> orjson.dumps(9007199254740992) b'9007199254740992' >>> orjson.dumps(9007199254740992, option=orjson.OPT_STRICT_INTEGER) JSONEncodeError: Integer exceeds 53-bit range >>> orjson.dumps(-9007199254740992, option=orjson.OPT_STRICT_INTEGER) JSONEncodeError: Integer exceeds 53-bit range ``` ### numpy orjson natively serializes `numpy.ndarray` and individual `numpy.float64`, `numpy.float32`, `numpy.int64`, `numpy.int32`, `numpy.int16`, `numpy.int8`, `numpy.uint64`, `numpy.uint32`, `numpy.uint16`, `numpy.uint8`, `numpy.uintp`, `numpy.intp`, `numpy.datetime64`, and `numpy.bool` instances. orjson is faster than all compared libraries at serializing numpy instances. Serializing numpy data requires specifying `option=orjson.OPT_SERIALIZE_NUMPY`. ```python >>> import orjson, numpy >>> orjson.dumps( numpy.array([[1, 2, 3], [4, 5, 6]]), option=orjson.OPT_SERIALIZE_NUMPY, ) b'[[1,2,3],[4,5,6]]' ``` The array must be a contiguous C array (`C_CONTIGUOUS`) and one of the supported datatypes. Note a difference between serializing `numpy.float32` using `ndarray.tolist()` or `orjson.dumps(..., option=orjson.OPT_SERIALIZE_NUMPY)`: `tolist()` converts to a `double` before serializing and orjson's native path does not. This can result in different rounding. `numpy.datetime64` instances are serialized as RFC 3339 strings and datetime options affect them. ```python >>> import orjson, numpy >>> orjson.dumps( numpy.datetime64("2021-01-01T00:00:00.172"), option=orjson.OPT_SERIALIZE_NUMPY, ) b'"2021-01-01T00:00:00.172000"' >>> orjson.dumps( numpy.datetime64("2021-01-01T00:00:00.172"), option=( orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_NAIVE_UTC | orjson.OPT_OMIT_MICROSECONDS ), ) b'"2021-01-01T00:00:00+00:00"' ``` If an array is not a contiguous C array, contains an unsupported datatype, or contains a `numpy.datetime64` using an unsupported representation (e.g., picoseconds), orjson falls through to `default`. In `default`, `obj.tolist()` can be specified. If an array is malformed, which is not expected, `orjson.JSONEncodeError` is raised. This measures serializing 92MiB of JSON from an `numpy.ndarray` with dimensions of `(50000, 100)` and `numpy.float64` values: | Library | Latency (ms) | RSS diff (MiB) | vs. orjson | |------------|----------------|------------------|--------------| | orjson | 194 | 99 | 1.0 | | ujson | | | | | rapidjson | 3,048 | 309 | 15.7 | | simplejson | 3,023 | 297 | 15.6 | | json | 3,133 | 297 | 16.1 | This measures serializing 100MiB of JSON from an `numpy.ndarray` with dimensions of `(100000, 100)` and `numpy.int32` values: | Library | Latency (ms) | RSS diff (MiB) | vs. orjson | |------------|----------------|------------------|--------------| | orjson | 178 | 115 | 1.0 | | ujson | | | | | rapidjson | 1,512 | 551 | 8.5 | | simplejson | 1,606 | 504 | 9.0 | | json | 1,506 | 503 | 8.4 | This measures serializing 105MiB of JSON from an `numpy.ndarray` with dimensions of `(100000, 200)` and `numpy.bool` values: | Library | Latency (ms) | RSS diff (MiB) | vs. orjson | |------------|----------------|------------------|--------------| | orjson | 157 | 120 | 1.0 | | ujson | | | | | rapidjson | 710 | 327 | 4.5 | | simplejson | 931 | 398 | 5.9 | | json | 996 | 400 | 6.3 | In these benchmarks, orjson serializes natively, ujson is blank because it does not support a `default` parameter, and the other libraries serialize `ndarray.tolist()` via `default`. The RSS column measures peak memory usage during serialization. This can be reproduced using the `pynumpy` script. orjson does not have an installation or compilation dependency on numpy. The implementation is independent, reading `numpy.ndarray` using `PyArrayInterface`. ### str orjson is strict about UTF-8 conformance. This is stricter than the standard library's json module, which will serialize and deserialize UTF-16 surrogates, e.g., "\ud800", that are invalid UTF-8. If `orjson.dumps()` is given a `str` that does not contain valid UTF-8, `orjson.JSONEncodeError` is raised. If `loads()` receives invalid UTF-8, `orjson.JSONDecodeError` is raised. orjson and rapidjson are the only compared JSON libraries to consistently error on bad input. ```python >>> import orjson, ujson, rapidjson, json >>> orjson.dumps('\ud800') JSONEncodeError: str is not valid UTF-8: surrogates not allowed >>> ujson.dumps('\ud800') UnicodeEncodeError: 'utf-8' codec ... >>> rapidjson.dumps('\ud800') UnicodeEncodeError: 'utf-8' codec ... >>> json.dumps('\ud800') '"\\ud800"' >>> orjson.loads('"\\ud800"') JSONDecodeError: unexpected end of hex escape at line 1 column 8: line 1 column 1 (char 0) >>> ujson.loads('"\\ud800"') '' >>> rapidjson.loads('"\\ud800"') ValueError: Parse error at offset 1: The surrogate pair in string is invalid. >>> json.loads('"\\ud800"') '\ud800' ``` To make a best effort at deserializing bad input, first decode `bytes` using the `replace` or `lossy` argument for `errors`: ```python >>> import orjson >>> orjson.loads(b'"\xed\xa0\x80"') JSONDecodeError: str is not valid UTF-8: surrogates not allowed >>> orjson.loads(b'"\xed\xa0\x80"'.decode("utf-8", "replace")) '���' ``` ### uuid orjson serializes `uuid.UUID` instances to [RFC 4122](https://tools.ietf.org/html/rfc4122) format, e.g., "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". ``` python >>> import orjson, uuid >>> orjson.dumps(uuid.UUID('f81d4fae-7dec-11d0-a765-00a0c91e6bf6')) b'"f81d4fae-7dec-11d0-a765-00a0c91e6bf6"' >>> orjson.dumps(uuid.uuid5(uuid.NAMESPACE_DNS, "python.org")) b'"886313e1-3b8a-5372-9b90-0c9aee199e5d"' ``` ## Testing The library has comprehensive tests. There are tests against fixtures in the [JSONTestSuite](https://github.com/nst/JSONTestSuite) and [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) repositories. It is tested to not crash against the [Big List of Naughty Strings](https://github.com/minimaxir/big-list-of-naughty-strings). It is tested to not leak memory. It is tested to not crash against and not accept invalid UTF-8. There are integration tests exercising the library's use in web servers (gunicorn using multiprocess/forked workers) and when multithreaded. It also uses some tests from the ultrajson library. orjson is the most correct of the compared libraries. This graph shows how each library handles a combined 342 JSON fixtures from the [JSONTestSuite](https://github.com/nst/JSONTestSuite) and [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) tests: | Library | Invalid JSON documents not rejected | Valid JSON documents not deserialized | |------------|---------------------------------------|-----------------------------------------| | orjson | 0 | 0 | | ujson | 31 | 0 | | rapidjson | 6 | 0 | | simplejson | 10 | 0 | | json | 17 | 0 | This shows that all libraries deserialize valid JSON but only orjson correctly rejects the given invalid JSON fixtures. Errors are largely due to accepting invalid strings and numbers. The graph above can be reproduced using the `pycorrectness` script. ## Performance Serialization and deserialization performance of orjson is better than ultrajson, rapidjson, simplejson, or json. The benchmarks are done on fixtures of real data: * twitter.json, 631.5KiB, results of a search on Twitter for "一", containing CJK strings, dictionaries of strings and arrays of dictionaries, indented. * github.json, 55.8KiB, a GitHub activity feed, containing dictionaries of strings and arrays of dictionaries, not indented. * citm_catalog.json, 1.7MiB, concert data, containing nested dictionaries of strings and arrays of integers, indented. * canada.json, 2.2MiB, coordinates of the Canadian border in GeoJSON format, containing floats and arrays, indented. ### Latency ![Serialization](doc/serialization.png) ![Deserialization](doc/deserialization.png) #### twitter.json serialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 0.3 | 3560 | 1 | | ujson | 2.1 | 473 | 7.5 | | rapidjson | 1.7 | 596 | 5.9 | | simplejson | 3.1 | 324 | 10.8 | | json | 2.5 | 397 | 8.9 | #### twitter.json deserialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 1.2 | 811 | 1 | | ujson | 2.9 | 347 | 2.3 | | rapidjson | 5.1 | 197 | 4.1 | | simplejson | 2.8 | 352 | 2.3 | | json | 3.3 | 299 | 2.7 | #### github.json serialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 0 | 39916 | 1 | | ujson | 0.2 | 4969 | 8 | | rapidjson | 0.2 | 5754 | 6.9 | | simplejson | 0.3 | 2916 | 13.7 | | json | 0.3 | 3916 | 10.3 | #### github.json deserialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 0.1 | 9879 | 1 | | ujson | 0.2 | 4059 | 2.3 | | rapidjson | 0.3 | 3772 | 2.6 | | simplejson | 0.2 | 5092 | 1.9 | | json | 0.2 | 4944 | 2 | #### citm_catalog.json serialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 0.6 | 1601 | 1 | | ujson | 2.9 | 340 | 4.8 | | rapidjson | 2.3 | 429 | 3.8 | | simplejson | 12.5 | 79 | 20.3 | | json | 5.7 | 176 | 9.2 | #### citm_catalog.json deserialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 2.9 | 341 | 1 | | ujson | 5 | 202 | 1.7 | | rapidjson | 8.3 | 119 | 2.8 | | simplejson | 6.6 | 151 | 2.2 | | json | 7 | 141 | 2.4 | #### canada.json serialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 5.3 | 186 | 1 | | ujson | 17.2 | 57 | 3.2 | | rapidjson | 45.3 | 22 | 8.5 | | simplejson | 70.9 | 14 | 13.3 | | json | 49.7 | 20 | 9.3 | #### canada.json deserialization | Library | Median latency (milliseconds) | Operations per second | Relative (latency) | |------------|---------------------------------|-------------------------|----------------------| | orjson | 6.7 | 149 | 1 | | ujson | 15.2 | 66 | 2.3 | | rapidjson | 30.1 | 33 | 4.5 | | simplejson | 29.9 | 32 | 4.5 | | json | 30.4 | 32 | 4.5 | ### Memory orjson as of 3.7.0 has higher baseline memory usage than other libraries due to a persistent buffer used for parsing. Incremental memory usage when deserializing is similar to the standard library and other third-party libraries. This measures, in the first column, RSS after importing a library and reading the fixture, and in the second column, increases in RSS after repeatedly calling `loads()` on the fixture. #### twitter.json | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) | |------------|----------------------------|---------------------------------| | orjson | 15.7 | 3.4 | | ujson | 16.4 | 3.4 | | rapidjson | 16.6 | 4.4 | | simplejson | 14.5 | 1.8 | | json | 13.9 | 1.8 | #### github.json | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) | |------------|----------------------------|---------------------------------| | orjson | 15.2 | 0.4 | | ujson | 15.4 | 0.4 | | rapidjson | 15.7 | 0.5 | | simplejson | 13.7 | 0.2 | | json | 13.3 | 0.1 | #### citm_catalog.json | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) | |------------|----------------------------|---------------------------------| | orjson | 16.8 | 10.1 | | ujson | 17.3 | 10.2 | | rapidjson | 17.6 | 28.7 | | simplejson | 15.8 | 30.1 | | json | 14.8 | 20.5 | #### canada.json | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) | |------------|----------------------------|---------------------------------| | orjson | 17.2 | 22.1 | | ujson | 17.4 | 18.3 | | rapidjson | 18 | 23.5 | | simplejson | 15.7 | 21.4 | | json | 15.4 | 20.4 | ### Reproducing The above was measured using Python 3.11.6 on Linux (amd64) with orjson 3.9.11, ujson 5.9.0, python-rapidson 1.14, and simplejson 3.19.2. The latency results can be reproduced using the `pybench` and `graph` scripts. The memory results can be reproduced using the `pymem` script. ## Questions ### Why can't I install it from PyPI? Probably `pip` needs to be upgraded to version 20.3 or later to support the latest manylinux_x_y or universal2 wheel formats. ### "Cargo, the Rust package manager, is not installed or is not on PATH." This happens when there are no binary wheels (like manylinux) for your platform on PyPI. You can install [Rust](https://www.rust-lang.org/) through `rustup` or a package manager and then it will compile. ### Will it deserialize to dataclasses, UUIDs, decimals, etc or support object_hook? No. This requires a schema specifying what types are expected and how to handle errors etc. This is addressed by data validation libraries a level above this. ### Will it serialize to `str`? No. `bytes` is the correct type for a serialized blob. ## Packaging To package orjson requires at least [Rust](https://www.rust-lang.org/) 1.72 and the [maturin](https://github.com/PyO3/maturin) build tool. The recommended build command is: ```sh maturin build --release --strip ``` It benefits from also having a C build environment to compile a faster deserialization backend. See this project's `manylinux_2_28` builds for an example using clang and LTO. The project's own CI tests against `nightly-2024-02-13` and stable 1.65. It is prudent to pin the nightly version because that channel can introduce breaking changes. orjson is tested for amd64, aarch64, arm7, ppc64le, and s390x on Linux. It is tested for amd64 on macOS and cross-compiles for aarch64. For Windows it is tested on amd64 and i686. There are no runtime dependencies other than libc. The source distribution on PyPI contains all dependencies' source and can be built without network access. The file can be downloaded from `https://files.pythonhosted.org/packages/source/o/orjson/orjson-${version}.tar.gz`. orjson's tests are included in the source distribution on PyPI. The requirements to run the tests are specified in `test/requirements.txt`. The tests should be run as part of the build. It can be run with `pytest -q test`. ## License orjson was written by ijl <>, copyright 2018 - 2024, available to you under either the Apache 2 license or MIT license at your choice. orjson-3.9.15/bench/000077500000000000000000000000001456615046100142125ustar00rootroot00000000000000orjson-3.9.15/bench/__init__.py000066400000000000000000000000001456615046100163110ustar00rootroot00000000000000orjson-3.9.15/bench/benchmark_dumps.py000066400000000000000000000011151456615046100177240ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from json import loads as json_loads import pytest from .data import fixtures, libraries from .util import read_fixture_obj @pytest.mark.parametrize("library", libraries) @pytest.mark.parametrize("fixture", fixtures) def test_dumps(benchmark, fixture, library): dumper, loader = libraries[library] benchmark.group = f"{fixture} serialization" benchmark.extra_info["lib"] = library data = read_fixture_obj(f"{fixture}.xz") benchmark.extra_info["correct"] = json_loads(dumper(data)) == data benchmark(dumper, data) orjson-3.9.15/bench/benchmark_empty.py000066400000000000000000000006761456615046100177450ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from json import loads as json_loads import pytest from .data import libraries @pytest.mark.parametrize("data", ["[]", "{}", '""']) @pytest.mark.parametrize("library", libraries) def test_empty(benchmark, data, library): dumper, loader = libraries[library] benchmark.extra_info["correct"] = json_loads(dumper(loader(data))) == json_loads( data ) benchmark(loader, data) orjson-3.9.15/bench/benchmark_loads.py000066400000000000000000000011511456615046100176760ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from json import loads as json_loads import pytest from .data import fixtures, libraries from .util import read_fixture @pytest.mark.parametrize("fixture", fixtures) @pytest.mark.parametrize("library", libraries) def test_loads(benchmark, fixture, library): dumper, loader = libraries[library] benchmark.group = f"{fixture} deserialization" benchmark.extra_info["lib"] = library data = read_fixture(f"{fixture}.xz") benchmark.extra_info["correct"] = json_loads(dumper(loader(data))) == json_loads( data ) benchmark(loader, data) orjson-3.9.15/bench/data.py000066400000000000000000000024641456615046100155030ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from json import dumps as _json_dumps from json import loads as json_loads from rapidjson import dumps as _rapidjson_dumps from rapidjson import loads as rapidjson_loads from simplejson import dumps as _simplejson_dumps from simplejson import loads as simplejson_loads from ujson import dumps as _ujson_dumps from ujson import loads as ujson_loads from orjson import dumps as _orjson_dumps from orjson import loads as orjson_loads # dumps wrappers that return UTF-8 def orjson_dumps(obj): return _orjson_dumps(obj) def ujson_dumps(obj): return _ujson_dumps(obj).encode("utf-8") def rapidjson_dumps(obj): return _rapidjson_dumps(obj).encode("utf-8") def json_dumps(obj): return _json_dumps(obj).encode("utf-8") def simplejson_dumps(obj): return _simplejson_dumps(obj).encode("utf-8") # Add new libraries here (pair of UTF-8 dumper, loader) libraries = { "orjson": (orjson_dumps, orjson_loads), "ujson": (ujson_dumps, ujson_loads), "json": (json_dumps, json_loads), "rapidjson": (rapidjson_dumps, rapidjson_loads), "simplejson": (simplejson_dumps, simplejson_loads), } # Add new JSON files here (corresponding to ../data/*.json.xz) fixtures = [ "canada.json", "citm_catalog.json", "github.json", "twitter.json", ] orjson-3.9.15/bench/requirements.txt000066400000000000000000000001571456615046100175010ustar00rootroot00000000000000memory-profiler pandas pytest-benchmark pytest-random-order python-rapidjson seaborn simplejson tabulate ujson orjson-3.9.15/bench/run_default000077500000000000000000000006071456615046100164530ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import sys import os os.sched_setaffinity(os.getpid(), {0, 1}) from orjson import dumps, OPT_SERIALIZE_NUMPY class Custom: pass def default(_): return None n = int(sys.argv[1]) if len(sys.argv) >= 2 else 10000 obj = [[Custom()] * 1000] * 10 for _ in range(n): dumps(obj, default, OPT_SERIALIZE_NUMPY) orjson-3.9.15/bench/run_func000077500000000000000000000010321456615046100157530ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import sys import lzma import os import gc gc.disable() os.sched_setaffinity(os.getpid(), {0, 1}) from orjson import dumps, loads filename = sys.argv[1] n = int(sys.argv[3]) if len(sys.argv) >= 4 else 1000 with lzma.open(filename, "r") as fileh: file_bytes = fileh.read() if sys.argv[2] == "dumps": file_obj = loads(file_bytes) for _ in range(n): dumps(file_obj) elif sys.argv[2] == "loads": for _ in range(n): loads(file_bytes) orjson-3.9.15/bench/run_mem000077500000000000000000000016671456615046100156140ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import sys import lzma import gc import psutil filename = sys.argv[1] with lzma.open(filename, "r") as fileh: fixture = fileh.read() proc = psutil.Process() lib_name = sys.argv[2] if lib_name == "json": from json import dumps, loads elif lib_name == "orjson": from orjson import dumps, loads elif lib_name == "rapidjson": from rapidjson import dumps, loads elif lib_name == "simplejson": from simplejson import dumps, loads elif lib_name == "ujson": from ujson import dumps, loads else: raise NotImplementedError gc.collect() mem_before = proc.memory_info().rss for _ in range(100): val = loads(fixture) mem_after = proc.memory_info().rss mem_diff = mem_after - mem_before from json import loads as json_loads correct = 1 if (json_loads(fixture) == json_loads(dumps(loads(fixture)))) else 0 print(f"{mem_before},{mem_diff},{correct}") orjson-3.9.15/bench/util.py000066400000000000000000000012541456615046100155430ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import lzma import os from functools import lru_cache from pathlib import Path from typing import Any import orjson dirname = os.path.join(os.path.dirname(__file__), "../data") if hasattr(os, "sched_setaffinity"): os.sched_setaffinity(os.getpid(), {0, 1}) @lru_cache(maxsize=None) def read_fixture(filename: str) -> bytes: path = Path(dirname, filename) if path.suffix == ".xz": contents = lzma.decompress(path.read_bytes()) else: contents = path.read_bytes() return contents @lru_cache(maxsize=None) def read_fixture_obj(filename: str) -> Any: return orjson.loads(read_fixture(filename)) orjson-3.9.15/build.rs000066400000000000000000000036321456615046100146040ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use std::env; fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=include/yyjson/*"); println!("cargo:rerun-if-env-changed=CC"); println!("cargo:rerun-if-env-changed=CFLAGS"); println!("cargo:rerun-if-env-changed=LDFLAGS"); println!("cargo:rerun-if-env-changed=RUSTFLAGS"); println!("cargo:rerun-if-env-changed=ORJSON_DISABLE_YYJSON"); for cfg in pyo3_build_config::get().build_script_outputs() { println!("{cfg}"); } if let Some(true) = version_check::supports_feature("core_intrinsics") { println!("cargo:rustc-cfg=feature=\"intrinsics\""); } if let Some(true) = version_check::supports_feature("optimize_attribute") { println!("cargo:rustc-cfg=feature=\"optimize\""); } if let Some(true) = version_check::supports_feature("strict_provenance") { println!("cargo:rustc-cfg=feature=\"strict_provenance\""); } if env::var("ORJSON_DISABLE_YYJSON").is_ok() { if env::var("CARGO_FEATURE_YYJSON").is_ok() { panic!("ORJSON_DISABLE_YYJSON and --features=yyjson both enabled.") } } else { match cc::Build::new() .file("include/yyjson/yyjson.c") .include("include/yyjson") .define("YYJSON_DISABLE_NON_STANDARD", "1") .define("YYJSON_DISABLE_UTF8_VALIDATION", "1") .define("YYJSON_DISABLE_UTILS", "1") .define("YYJSON_DISABLE_WRITER", "1") .try_compile("yyjson") { Ok(_) => { println!("cargo:rustc-cfg=feature=\"yyjson\""); } Err(_) => { if env::var("CARGO_FEATURE_YYJSON").is_ok() { panic!("yyjson was enabled but the build failed. To build with a different backend do not specify the feature.") } } } } } orjson-3.9.15/ci/000077500000000000000000000000001456615046100135265ustar00rootroot00000000000000orjson-3.9.15/ci/azure-macos.yml000066400000000000000000000035251456615046100165040ustar00rootroot00000000000000parameters: interpreter: '' macosx_deployment_target: '' toolchain: '' steps: - bash: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $(toolchain) --profile minimal -y rustup component add rust-src --toolchain $(toolchain)-x86_64-apple-darwin rustup target add aarch64-apple-darwin rustup default $(toolchain) - bash: pip install --upgrade pip pip "maturin>=1,<2" wheel displayName: build dependencies - bash: pip install -r test/requirements.txt -r integration/requirements.txt displayName: test dependencies - bash: | mkdir .cargo cp ci/config.toml .cargo/config - bash: | PATH=$HOME/.cargo/bin:$PATH \ MACOSX_DEPLOYMENT_TARGET=$(macosx_deployment_target) \ PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \ maturin build --release --strip --features=no-panic,unstable-simd,yyjson --interpreter $(interpreter) --target=universal2-apple-darwin env: CC: "clang" CFLAGS: "-O2 -fstrict-aliasing -flto=full" LDFLAGS: "-O2 -fstrict-aliasing -flto=full -Wl,--as-needed" CFLAGS_x86_64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -march=x86-64-v2 -mtune=generic" CFLAGS_aarch64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -mcpu=apple-m1 -mtune=generic" RUSTFLAGS: "-C lto=fat -Z mir-opt-level=4 -Z virtual-function-elimination -D warnings" CARGO_UNSTABLE_SPARSE_REGISTRY: "true" displayName: build universal2 - bash: pip install target/wheels/orjson*universal2.whl displayName: install universal2 - bash: pytest -s -rxX -v test env: PYTHONMALLOC: "debug" displayName: pytest - bash: ./integration/run thread displayName: thread - bash: ./integration/run http displayName: http - bash: ./integration/run init displayName: init - bash: ./ci/deploy target/wheels/*_universal2.whl displayName: deploy universal2 orjson-3.9.15/ci/azure-pipelines.yml000066400000000000000000000126351456615046100173740ustar00rootroot00000000000000variables: toolchain: nightly-2024-02-13 jobs: - job: macos_python312_univeral2 pool: vmImage: macOS-11 variables: interpreter: python3.12 macosx_deployment_target: '10.15' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.12.0' addToPath: true allowUnstable: true - checkout: self - template: ./azure-macos.yml - job: macos_python311_univeral2 pool: vmImage: macOS-11 variables: interpreter: python3.11 macosx_deployment_target: '10.15' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.11.4' addToPath: true allowUnstable: true - checkout: self - template: ./azure-macos.yml - job: macos_python310_univeral2 pool: vmImage: macOS-11 variables: interpreter: python3.10 macosx_deployment_target: '10.15' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.10' addToPath: true - checkout: self - template: ./azure-macos.yml - job: macos_python39_univeral2 pool: vmImage: macOS-11 variables: interpreter: python3.9 macosx_deployment_target: '10.15' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.9' addToPath: true - checkout: self - template: ./azure-macos.yml - job: macos_python38_univeral2 pool: vmImage: macOS-11 variables: interpreter: python3.8 macosx_deployment_target: '10.15' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.8' addToPath: true - checkout: self - template: ./azure-macos.yml - job: win_python312_amd64 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.12.0\x64\python.exe rustup: https://win.rustup.rs/x86_64 target: x86_64-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.12.0' addToPath: true allowUnstable: true architecture: 'x64' - checkout: self - template: ./azure-win.yml - job: win_python311_amd64 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.11.4\x64\python.exe rustup: https://win.rustup.rs/x86_64 target: x86_64-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.11.4' addToPath: true architecture: 'x64' - checkout: self - template: ./azure-win.yml - job: win_python310_amd64 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.10.8\x64\python.exe rustup: https://win.rustup.rs/x86_64 target: x86_64-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.10.8' addToPath: true architecture: 'x64' - checkout: self - template: ./azure-win.yml - job: win_python39_amd64 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.9.13\x64\python.exe rustup: https://win.rustup.rs/x86_64 target: x86_64-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.9.13' addToPath: true architecture: 'x64' - checkout: self - template: ./azure-win.yml - job: win_python38_amd64 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.8.10\x64\python.exe rustup: https://win.rustup.rs/x86_64 target: x86_64-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.8.10' addToPath: true architecture: 'x64' - checkout: self - template: ./azure-win.yml - job: win_python312_x86 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.12.0\x86\python.exe rustup: https://win.rustup.rs/x86 target: i686-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.12.0' addToPath: true allowUnstable: true architecture: 'x86' - checkout: self - job: win_python311_x86 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.11.4\x86\python.exe rustup: https://win.rustup.rs/x86 target: i686-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.11.4' addToPath: true architecture: 'x86' - checkout: self - template: ./azure-win.yml - job: win_python310_x86 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.10.8\x86\python.exe rustup: https://win.rustup.rs/x86 target: i686-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.10.8' addToPath: true architecture: 'x86' - checkout: self - template: ./azure-win.yml - job: win_python39_x86 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.9.13\x86\python.exe rustup: https://win.rustup.rs/x86 target: i686-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.9.13' addToPath: true architecture: 'x86' - checkout: self - template: ./azure-win.yml - job: win_python38_x86 pool: vmImage: windows-2022 variables: interpreter: C:\hostedtoolcache\windows\Python\3.8.10\x86\python.exe rustup: https://win.rustup.rs/x86 target: i686-pc-windows-msvc steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.8.10' addToPath: true architecture: 'x86' - checkout: self - template: ./azure-win.yml orjson-3.9.15/ci/azure-win.yml000066400000000000000000000025161456615046100161760ustar00rootroot00000000000000parameters: interpreter: '' rustup: '' target: '' toolchain: '' steps: - script: | curl $(rustup) -o rustup-init.exe rustup-init.exe -y --default-host $(target) --default-toolchain $(toolchain)-$(target) --profile minimal set PATH=%PATH%;%USERPROFILE%\.cargo\bin rustup default $(toolchain)-$(target) rustup component add rust-src mkdir .cargo cp ci/config.toml .cargo/config.toml echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" displayName: rustup - script: python.exe -m pip install --upgrade pip "maturin>=1,<2" wheel displayName: build dependencies - script: python.exe -m pip install -r test\requirements.txt -r integration\requirements.txt displayName: test dependencies - script: maturin.exe build --release --features=no-panic,unstable-simd,yyjson --strip --interpreter $(interpreter) --target $(target) displayName: build env: RUSTFLAGS: "-Z mir-opt-level=4" - script: python.exe -m pip install orjson --no-index --find-links=D:\a\1\s\target\wheels displayName: install - script: python.exe -m pytest -s -rxX -v test env: PYTHONMALLOC: "debug" displayName: pytest - script: python.exe integration\thread displayName: thread - script: python.exe integration\init displayName: init - bash: ./ci/deploy /d/a/1/s/target/wheels/*.whl displayName: deploy orjson-3.9.15/ci/config.toml000066400000000000000000000005121456615046100156660ustar00rootroot00000000000000[unstable] build-std = ["core", "std", "alloc", "proc_macro", "panic_abort"] build-std-features = ["panic_immediate_abort"] [target.x86_64-apple-darwin] linker = "clang" rustflags = ["-C", "target-cpu=x86-64-v2", "-Z", "tune-cpu=generic"] [target.aarch64-apple-darwin] linker = "clang" rustflags = ["-C", "target-cpu=apple-m1"] orjson-3.9.15/ci/deploy000077500000000000000000000004431456615046100147510ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail if [ -z ${DRONE_TAG+x} ]; then tag=$(git name-rev --tags --name-only $(git rev-parse HEAD)) else tag="$DRONE_TAG" fi echo "$tag" if [[ "$tag" == "undefined" ]]; then echo "not on a tag" exit 0 fi maturin upload --skip-existing "$1" orjson-3.9.15/ci/sdist.toml000066400000000000000000000001541456615046100155510ustar00rootroot00000000000000[source.crates-io] replace-with = "vendored-sources" [source.vendored-sources] directory = "include/cargo" orjson-3.9.15/data/000077500000000000000000000000001456615046100140445ustar00rootroot00000000000000orjson-3.9.15/data/blns.txt.xz000066400000000000000000000211141456615046100162020ustar00rootroot000000000000007zXZִF!Xo" ]F!}ZL_)&oxZAeӰ79G;i~B}ѭl=15ۣ@we4Sc[M ]VSnjf06Wx[x`L\3Xes96C]*FGwl4#oHjOW$ڌ̳ȐxR>R nq%̕B~g=XTxF|]'D]UJ@ۨ3h; ݛ@D{lVIv.+Hn`nxk^ve 5L~tZD%zE| >;ہ"' m _fz_ya*ҡ4LyɠA967x$ZRrz_RODI+Jrw=lW%e#Hr:N]iE|H%&UWV10G\whϭ>koO4 WkscRȷXCve <)6w;K?髐Y6V{wGkJ~oZRT9cBČJb"T$UlMup X6*lL΅Xgv1[$$*5{s3Am$^ }ElZ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/t.R$@SW#z`! U3͝!骛S{5o7#| hx( |ӣU_;1ըCU'(^XMp*&HQN-Q<=k±[%u\mӔ`sSF YiCG"ypݓӱD^`"-bzX/<ڪn͹R,{hWk"HM:v5 +31+쯓?d3P XGtgYZorjson-3.9.15/data/issue331_2.json.xz000066400000000000000000000011201456615046100171710ustar00rootroot000000000000007zXZִF!XL]=擮d d?@ 2%2hg1bb#*έKC?)m29O sqZ=l<0 aຉ`ѨOg/-Dx,颯.+O.fM*-U# _kWͧ;^<%M$wWl6?eWCJUD;pAJ|S6P iF/9_UEw\p6W6n/8čc&:?qn2t4!Vr|p=/t.R$@SW#z`! U3͝!骛S{5o7#| hx( |ӣU_;1ըCU'(^XMp*&HQN-Q<=k±[%u\mӔ`sSF YiCG"ypݓӱD^`"-bzX/<ڪn͹R,{hWk"HM:v5 +31+쯓K4!g| ѱgYZorjson-3.9.15/data/jsonchecker/000077500000000000000000000000001456615046100163425ustar00rootroot00000000000000orjson-3.9.15/data/jsonchecker/fail01.json000066400000000000000000000000741456615046100203120ustar00rootroot00000000000000"A JSON payload should be an object or array, not a string."orjson-3.9.15/data/jsonchecker/fail02.json000066400000000000000000000000211456615046100203030ustar00rootroot00000000000000["Unclosed array"orjson-3.9.15/data/jsonchecker/fail03.json000066400000000000000000000000451456615046100203120ustar00rootroot00000000000000{unquoted_key: "keys must be quoted"}orjson-3.9.15/data/jsonchecker/fail04.json000066400000000000000000000000201456615046100203040ustar00rootroot00000000000000["extra comma",]orjson-3.9.15/data/jsonchecker/fail05.json000066400000000000000000000000301456615046100203060ustar00rootroot00000000000000["double extra comma",,]orjson-3.9.15/data/jsonchecker/fail06.json000066400000000000000000000000321456615046100203110ustar00rootroot00000000000000[ , "<-- missing value"]orjson-3.9.15/data/jsonchecker/fail07.json000066400000000000000000000000321456615046100203120ustar00rootroot00000000000000["Comma after the close"],orjson-3.9.15/data/jsonchecker/fail08.json000066400000000000000000000000201456615046100203100ustar00rootroot00000000000000["Extra close"]]orjson-3.9.15/data/jsonchecker/fail09.json000066400000000000000000000000261456615046100203170ustar00rootroot00000000000000{"Extra comma": true,}orjson-3.9.15/data/jsonchecker/fail10.json000066400000000000000000000000721456615046100203100ustar00rootroot00000000000000{"Extra value after close": true} "misplaced quoted value"orjson-3.9.15/data/jsonchecker/fail11.json000066400000000000000000000000351456615046100203100ustar00rootroot00000000000000{"Illegal expression": 1 + 2}orjson-3.9.15/data/jsonchecker/fail12.json000066400000000000000000000000371456615046100203130ustar00rootroot00000000000000{"Illegal invocation": alert()}orjson-3.9.15/data/jsonchecker/fail13.json000066400000000000000000000000531456615046100203120ustar00rootroot00000000000000{"Numbers cannot have leading zeroes": 013}orjson-3.9.15/data/jsonchecker/fail14.json000066400000000000000000000000371456615046100203150ustar00rootroot00000000000000{"Numbers cannot be hex": 0x14}orjson-3.9.15/data/jsonchecker/fail15.json000066400000000000000000000000421456615046100203120ustar00rootroot00000000000000["Illegal backslash escape: \x15"]orjson-3.9.15/data/jsonchecker/fail16.json000066400000000000000000000000101456615046100203060ustar00rootroot00000000000000[\naked]orjson-3.9.15/data/jsonchecker/fail17.json000066400000000000000000000000421456615046100203140ustar00rootroot00000000000000["Illegal backslash escape: \017"]orjson-3.9.15/data/jsonchecker/fail18.json000066400000000000000000000000621456615046100203170ustar00rootroot00000000000000[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]orjson-3.9.15/data/jsonchecker/fail19.json000066400000000000000000000000261456615046100203200ustar00rootroot00000000000000{"Missing colon" null}orjson-3.9.15/data/jsonchecker/fail20.json000066400000000000000000000000271456615046100203110ustar00rootroot00000000000000{"Double colon":: null}orjson-3.9.15/data/jsonchecker/fail21.json000066400000000000000000000000401456615046100203050ustar00rootroot00000000000000{"Comma instead of colon", null}orjson-3.9.15/data/jsonchecker/fail22.json000066400000000000000000000000411456615046100203070ustar00rootroot00000000000000["Colon instead of comma": false]orjson-3.9.15/data/jsonchecker/fail23.json000066400000000000000000000000241456615046100203110ustar00rootroot00000000000000["Bad value", truth]orjson-3.9.15/data/jsonchecker/fail24.json000066400000000000000000000000201456615046100203060ustar00rootroot00000000000000['single quote']orjson-3.9.15/data/jsonchecker/fail25.json000066400000000000000000000000351456615046100203150ustar00rootroot00000000000000[" tab character in string "]orjson-3.9.15/data/jsonchecker/fail26.json000066400000000000000000000000461456615046100203200ustar00rootroot00000000000000["tab\ character\ in\ string\ "]orjson-3.9.15/data/jsonchecker/fail27.json000066400000000000000000000000161456615046100203160ustar00rootroot00000000000000["line break"]orjson-3.9.15/data/jsonchecker/fail28.json000066400000000000000000000000171456615046100203200ustar00rootroot00000000000000["line\ break"]orjson-3.9.15/data/jsonchecker/fail29.json000066400000000000000000000000041456615046100203150ustar00rootroot00000000000000[0e]orjson-3.9.15/data/jsonchecker/fail30.json000066400000000000000000000000051456615046100203060ustar00rootroot00000000000000[0e+]orjson-3.9.15/data/jsonchecker/fail31.json000066400000000000000000000000071456615046100203110ustar00rootroot00000000000000[0e+-1]orjson-3.9.15/data/jsonchecker/fail32.json000066400000000000000000000000501456615046100203100ustar00rootroot00000000000000{"Comma instead if closing brace": true,orjson-3.9.15/data/jsonchecker/fail33.json000066400000000000000000000000141456615046100203110ustar00rootroot00000000000000["mismatch"}orjson-3.9.15/data/jsonchecker/pass01.json000066400000000000000000000026411456615046100203470ustar00rootroot00000000000000[ "JSON Test Pattern pass1", {"object with 1 member":["array with 1 element"]}, {}, [], -42, true, false, null, { "integer": 1234567890, "real": -9876.543210, "e": 0.123456789e-12, "E": 1.234567890E+34, "": 23456789012E66, "zero": 0, "one": 1, "space": " ", "quote": "\"", "backslash": "\\", "controls": "\b\f\n\r\t", "slash": "/ & \/", "alpha": "abcdefghijklmnopqrstuvwyz", "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", "digit": "0123456789", "0123456789": "digit", "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", "true": true, "false": false, "null": null, "array":[ ], "object":{ }, "address": "50 St. James Street", "url": "http://www.JSON.org/", "comment": "// /* */": " ", " s p a c e d " :[1,2 , 3 , 4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", "quotes": "" \u0022 %22 0x22 034 "", "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" : "A key can be any string" }, 0.5 ,98.6 , 99.44 , 1066, 1e1, 0.1e1, 1e-1, 1e00,2e+00,2e-00 ,"rosebud"]orjson-3.9.15/data/jsonchecker/pass02.json000066400000000000000000000000641456615046100203450ustar00rootroot00000000000000[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]orjson-3.9.15/data/jsonchecker/pass03.json000066400000000000000000000002241456615046100203440ustar00rootroot00000000000000{ "JSON Test Pattern pass3": { "The outermost value": "must be an object or array.", "In this test": "It is an object." } } orjson-3.9.15/data/parsing/000077500000000000000000000000001456615046100155075ustar00rootroot00000000000000orjson-3.9.15/data/parsing/i_number_double_huge_neg_exp.json000066400000000000000000000000161456615046100242460ustar00rootroot00000000000000[123.456e-789]orjson-3.9.15/data/parsing/i_number_huge_exp.json000066400000000000000000000002111456615046100220600ustar00rootroot00000000000000[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]orjson-3.9.15/data/parsing/i_number_neg_int_huge_exp.json000066400000000000000000000000121456615046100235620ustar00rootroot00000000000000[-1e+9999]orjson-3.9.15/data/parsing/i_number_pos_double_huge_exp.json000066400000000000000000000000131456615046100242730ustar00rootroot00000000000000[1.5e+9999]orjson-3.9.15/data/parsing/i_number_real_neg_overflow.json000066400000000000000000000000201456615046100237510ustar00rootroot00000000000000[-123123e100000]orjson-3.9.15/data/parsing/i_number_real_pos_overflow.json000066400000000000000000000000171456615046100240070ustar00rootroot00000000000000[123123e100000]orjson-3.9.15/data/parsing/i_number_real_underflow.json000066400000000000000000000000171456615046100232700ustar00rootroot00000000000000[123e-10000000]orjson-3.9.15/data/parsing/i_number_too_big_neg_int.json000066400000000000000000000000411456615046100234020ustar00rootroot00000000000000[-123123123123123123123123123123]orjson-3.9.15/data/parsing/i_number_too_big_pos_int.json000066400000000000000000000000271456615046100234360ustar00rootroot00000000000000[100000000000000000000]orjson-3.9.15/data/parsing/i_number_very_big_negative_int.json000066400000000000000000000000631456615046100246230ustar00rootroot00000000000000[-237462374673276894279832749832423479823246327846]orjson-3.9.15/data/parsing/i_object_key_lone_2nd_surrogate.json000066400000000000000000000000141456615046100246760ustar00rootroot00000000000000{"\uDFAA":0}orjson-3.9.15/data/parsing/i_string_1st_surrogate_but_2nd_missing.json000066400000000000000000000000121456615046100262410ustar00rootroot00000000000000["\uDADA"]orjson-3.9.15/data/parsing/i_string_1st_valid_surrogate_2nd_invalid.json000066400000000000000000000000201456615046100265220ustar00rootroot00000000000000["\uD888\u1234"]orjson-3.9.15/data/parsing/i_string_UTF-16LE_with_BOM.json000066400000000000000000000000141456615046100231260ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_UTF-8_invalid_sequence.json000066400000000000000000000000121456615046100244720ustar00rootroot00000000000000["日ш"]orjson-3.9.15/data/parsing/i_string_UTF8_surrogate_U+D800.json000066400000000000000000000000071456615046100240110ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_incomplete_surrogate_and_escape_valid.json000066400000000000000000000000141456615046100300460ustar00rootroot00000000000000["\uD800\n"]orjson-3.9.15/data/parsing/i_string_incomplete_surrogate_pair.json000066400000000000000000000000131456615046100255370ustar00rootroot00000000000000["\uDd1ea"]orjson-3.9.15/data/parsing/i_string_incomplete_surrogates_escape_valid.json000066400000000000000000000000221456615046100274060ustar00rootroot00000000000000["\uD800\uD800\n"]orjson-3.9.15/data/parsing/i_string_invalid_lonely_surrogate.json000066400000000000000000000000121456615046100253740ustar00rootroot00000000000000["\ud800"]orjson-3.9.15/data/parsing/i_string_invalid_surrogate.json000066400000000000000000000000151456615046100240150ustar00rootroot00000000000000["\ud800abc"]orjson-3.9.15/data/parsing/i_string_invalid_utf-8.json000066400000000000000000000000051456615046100227440ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_inverted_surrogates_U+1D11E.json000066400000000000000000000000201456615046100253610ustar00rootroot00000000000000["\uDd1e\uD834"]orjson-3.9.15/data/parsing/i_string_iso_latin_1.json000066400000000000000000000000051456615046100224740ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_lone_second_surrogate.json000066400000000000000000000000121456615046100246540ustar00rootroot00000000000000["\uDFAA"]orjson-3.9.15/data/parsing/i_string_lone_utf8_continuation_byte.json000066400000000000000000000000051456615046100260130ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_not_in_unicode_range.json000066400000000000000000000000101456615046100244370ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_overlong_sequence_2_bytes.json000066400000000000000000000000061456615046100254460ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_overlong_sequence_6_bytes.json000066400000000000000000000000121456615046100254470ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_overlong_sequence_6_bytes_null.json000066400000000000000000000000121456615046100265010ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_truncated-utf-8.json000066400000000000000000000000061456615046100232260ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_utf16BE_no_BOM.json000066400000000000000000000000121456615046100226360ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_string_utf16LE_no_BOM.json000066400000000000000000000000121456615046100226500ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/i_structure_500_nested_arrays.json.xz000066400000000000000000000001201456615046100247120ustar00rootroot000000000000007zXZִF!X ]-JK ܢ/mOQޖ)4fgYZorjson-3.9.15/data/parsing/i_structure_UTF-8_BOM_empty_object.json000066400000000000000000000000051456615046100250710ustar00rootroot00000000000000{}orjson-3.9.15/data/parsing/n_array_1_true_without_comma.json000066400000000000000000000000101456615046100242420ustar00rootroot00000000000000[1 true]orjson-3.9.15/data/parsing/n_array_a_invalid_utf8.json000066400000000000000000000000041456615046100230030ustar00rootroot00000000000000[a]orjson-3.9.15/data/parsing/n_array_colon_instead_of_comma.json000066400000000000000000000000071456615046100245730ustar00rootroot00000000000000["": 1]orjson-3.9.15/data/parsing/n_array_comma_after_close.json000066400000000000000000000000051456615046100235520ustar00rootroot00000000000000[""],orjson-3.9.15/data/parsing/n_array_comma_and_number.json000066400000000000000000000000041456615046100233750ustar00rootroot00000000000000[,1]orjson-3.9.15/data/parsing/n_array_double_comma.json000066400000000000000000000000061456615046100225370ustar00rootroot00000000000000[1,,2]orjson-3.9.15/data/parsing/n_array_double_extra_comma.json000066400000000000000000000000071456615046100237430ustar00rootroot00000000000000["x",,]orjson-3.9.15/data/parsing/n_array_extra_close.json000066400000000000000000000000061456615046100224210ustar00rootroot00000000000000["x"]]orjson-3.9.15/data/parsing/n_array_extra_comma.json000066400000000000000000000000051456615046100224070ustar00rootroot00000000000000["",]orjson-3.9.15/data/parsing/n_array_incomplete.json000066400000000000000000000000041456615046100222460ustar00rootroot00000000000000["x"orjson-3.9.15/data/parsing/n_array_incomplete_invalid_value.json000066400000000000000000000000021456615046100251460ustar00rootroot00000000000000[xorjson-3.9.15/data/parsing/n_array_inner_array_no_comma.json000066400000000000000000000000061456615046100242720ustar00rootroot00000000000000[3[4]]orjson-3.9.15/data/parsing/n_array_invalid_utf8.json000066400000000000000000000000031456615046100225020ustar00rootroot00000000000000[]orjson-3.9.15/data/parsing/n_array_items_separated_by_semicolon.json000066400000000000000000000000051456615046100260230ustar00rootroot00000000000000[1:2]orjson-3.9.15/data/parsing/n_array_just_comma.json000066400000000000000000000000031456615046100222470ustar00rootroot00000000000000[,]orjson-3.9.15/data/parsing/n_array_just_minus.json000066400000000000000000000000031456615046100223060ustar00rootroot00000000000000[-]orjson-3.9.15/data/parsing/n_array_missing_value.json000066400000000000000000000000111456615046100227520ustar00rootroot00000000000000[ , ""]orjson-3.9.15/data/parsing/n_array_newlines_unclosed.json000066400000000000000000000000131456615046100236270ustar00rootroot00000000000000["a", 4 ,1,orjson-3.9.15/data/parsing/n_array_number_and_comma.json000066400000000000000000000000041456615046100233750ustar00rootroot00000000000000[1,]orjson-3.9.15/data/parsing/n_array_number_and_several_commas.json000066400000000000000000000000051456615046100253020ustar00rootroot00000000000000[1,,]orjson-3.9.15/data/parsing/n_array_spaces_vertical_tab_formfeed.json000066400000000000000000000000101456615046100257500ustar00rootroot00000000000000[" a"\f]orjson-3.9.15/data/parsing/n_array_star_inside.json000066400000000000000000000000031456615046100224120ustar00rootroot00000000000000[*]orjson-3.9.15/data/parsing/n_array_unclosed.json000066400000000000000000000000031456615046100217220ustar00rootroot00000000000000[""orjson-3.9.15/data/parsing/n_array_unclosed_trailing_comma.json000066400000000000000000000000031456615046100247670ustar00rootroot00000000000000[1,orjson-3.9.15/data/parsing/n_array_unclosed_with_new_lines.json000066400000000000000000000000101456615046100250160ustar00rootroot00000000000000[1, 1 ,1orjson-3.9.15/data/parsing/n_array_unclosed_with_object_inside.json000066400000000000000000000000031456615046100256360ustar00rootroot00000000000000[{}orjson-3.9.15/data/parsing/n_incomplete_false.json000066400000000000000000000000061456615046100222240ustar00rootroot00000000000000[fals]orjson-3.9.15/data/parsing/n_incomplete_null.json000066400000000000000000000000051456615046100221030ustar00rootroot00000000000000[nul]orjson-3.9.15/data/parsing/n_incomplete_true.json000066400000000000000000000000051456615046100221100ustar00rootroot00000000000000[tru]orjson-3.9.15/data/parsing/n_multidigit_number_then_00.json000066400000000000000000000000041456615046100237510ustar00rootroot00000000000000123orjson-3.9.15/data/parsing/n_number_++.json000066400000000000000000000000101456615046100204630ustar00rootroot00000000000000[++1234]orjson-3.9.15/data/parsing/n_number_+1.json000066400000000000000000000000041456615046100204740ustar00rootroot00000000000000[+1]orjson-3.9.15/data/parsing/n_number_+Inf.json000066400000000000000000000000061456615046100210520ustar00rootroot00000000000000[+Inf]orjson-3.9.15/data/parsing/n_number_-01.json000066400000000000000000000000051456615046100205570ustar00rootroot00000000000000[-01]orjson-3.9.15/data/parsing/n_number_-1.0..json000066400000000000000000000000071456615046100207150ustar00rootroot00000000000000[-1.0.]orjson-3.9.15/data/parsing/n_number_-2..json000066400000000000000000000000051456615046100205560ustar00rootroot00000000000000[-2.]orjson-3.9.15/data/parsing/n_number_-NaN.json000066400000000000000000000000061456615046100210140ustar00rootroot00000000000000[-NaN]orjson-3.9.15/data/parsing/n_number_.-1.json000066400000000000000000000000051456615046100205550ustar00rootroot00000000000000[.-1]orjson-3.9.15/data/parsing/n_number_.2e-3.json000066400000000000000000000000071456615046100210100ustar00rootroot00000000000000[.2e-3]orjson-3.9.15/data/parsing/n_number_0.1.2.json000066400000000000000000000000071456615046100207220ustar00rootroot00000000000000[0.1.2]orjson-3.9.15/data/parsing/n_number_0.3e+.json000066400000000000000000000000071456615046100210040ustar00rootroot00000000000000[0.3e+]orjson-3.9.15/data/parsing/n_number_0.3e.json000066400000000000000000000000061456615046100207300ustar00rootroot00000000000000[0.3e]orjson-3.9.15/data/parsing/n_number_0.e1.json000066400000000000000000000000061456615046100207260ustar00rootroot00000000000000[0.e1]orjson-3.9.15/data/parsing/n_number_0_capital_E+.json000066400000000000000000000000051456615046100224350ustar00rootroot00000000000000[0E+]orjson-3.9.15/data/parsing/n_number_0_capital_E.json000066400000000000000000000000041456615046100223610ustar00rootroot00000000000000[0E]orjson-3.9.15/data/parsing/n_number_0e+.json000066400000000000000000000000051456615046100206410ustar00rootroot00000000000000[0e+]orjson-3.9.15/data/parsing/n_number_0e.json000066400000000000000000000000041456615046100205650ustar00rootroot00000000000000[0e]orjson-3.9.15/data/parsing/n_number_1.0e+.json000066400000000000000000000000071456615046100210020ustar00rootroot00000000000000[1.0e+]orjson-3.9.15/data/parsing/n_number_1.0e-.json000066400000000000000000000000071456615046100210040ustar00rootroot00000000000000[1.0e-]orjson-3.9.15/data/parsing/n_number_1.0e.json000066400000000000000000000000061456615046100207260ustar00rootroot00000000000000[1.0e]orjson-3.9.15/data/parsing/n_number_1_000.json000066400000000000000000000000111456615046100207760ustar00rootroot00000000000000[1 000.0]orjson-3.9.15/data/parsing/n_number_1eE2.json000066400000000000000000000000061456615046100207570ustar00rootroot00000000000000[1eE2]orjson-3.9.15/data/parsing/n_number_2.e+3.json000066400000000000000000000000071456615046100210060ustar00rootroot00000000000000[2.e+3]orjson-3.9.15/data/parsing/n_number_2.e-3.json000066400000000000000000000000071456615046100210100ustar00rootroot00000000000000[2.e-3]orjson-3.9.15/data/parsing/n_number_2.e3.json000066400000000000000000000000061456615046100207320ustar00rootroot00000000000000[2.e3]orjson-3.9.15/data/parsing/n_number_9.e+.json000066400000000000000000000000061456615046100207310ustar00rootroot00000000000000[9.e+]orjson-3.9.15/data/parsing/n_number_Inf.json000066400000000000000000000000051456615046100207760ustar00rootroot00000000000000[Inf]orjson-3.9.15/data/parsing/n_number_NaN.json000066400000000000000000000000051456615046100207360ustar00rootroot00000000000000[NaN]orjson-3.9.15/data/parsing/n_number_U+FF11_fullwidth_digit_one.json000066400000000000000000000000051456615046100252220ustar00rootroot00000000000000[1]orjson-3.9.15/data/parsing/n_number_expression.json000066400000000000000000000000051456615046100224610ustar00rootroot00000000000000[1+2]orjson-3.9.15/data/parsing/n_number_hex_1_digit.json000066400000000000000000000000051456615046100224460ustar00rootroot00000000000000[0x1]orjson-3.9.15/data/parsing/n_number_hex_2_digits.json000066400000000000000000000000061456615046100226330ustar00rootroot00000000000000[0x42]orjson-3.9.15/data/parsing/n_number_infinity.json000066400000000000000000000000121456615046100221110ustar00rootroot00000000000000[Infinity]orjson-3.9.15/data/parsing/n_number_invalid+-.json000066400000000000000000000000071456615046100220420ustar00rootroot00000000000000[0e+-1]orjson-3.9.15/data/parsing/n_number_invalid-negative-real.json000066400000000000000000000000151456615046100244320ustar00rootroot00000000000000[-123.123foo]orjson-3.9.15/data/parsing/n_number_invalid-utf-8-in-bigger-int.json000066400000000000000000000000061456615046100253030ustar00rootroot00000000000000[123]orjson-3.9.15/data/parsing/n_number_invalid-utf-8-in-exponent.json000066400000000000000000000000061456615046100251140ustar00rootroot00000000000000[1e1]orjson-3.9.15/data/parsing/n_number_invalid-utf-8-in-int.json000066400000000000000000000000051456615046100240450ustar00rootroot00000000000000[0] orjson-3.9.15/data/parsing/n_number_minus_infinity.json000066400000000000000000000000131456615046100233250ustar00rootroot00000000000000[-Infinity]orjson-3.9.15/data/parsing/n_number_minus_sign_with_trailing_garbage.json000066400000000000000000000000061456615046100270320ustar00rootroot00000000000000[-foo]orjson-3.9.15/data/parsing/n_number_minus_space_1.json000066400000000000000000000000051456615046100230100ustar00rootroot00000000000000[- 1]orjson-3.9.15/data/parsing/n_number_neg_int_starting_with_zero.json000066400000000000000000000000061456615046100257130ustar00rootroot00000000000000[-012]orjson-3.9.15/data/parsing/n_number_neg_real_without_int_part.json000066400000000000000000000000071456615046100255230ustar00rootroot00000000000000[-.123]orjson-3.9.15/data/parsing/n_number_neg_with_garbage_at_end.json000066400000000000000000000000051456615046100250500ustar00rootroot00000000000000[-1x]orjson-3.9.15/data/parsing/n_number_real_garbage_after_e.json000066400000000000000000000000051456615046100243420ustar00rootroot00000000000000[1ea]orjson-3.9.15/data/parsing/n_number_real_with_invalid_utf8_after_e.json000066400000000000000000000000051456615046100264010ustar00rootroot00000000000000[1e]orjson-3.9.15/data/parsing/n_number_real_without_fractional_part.json000066400000000000000000000000041456615046100262170ustar00rootroot00000000000000[1.]orjson-3.9.15/data/parsing/n_number_starting_with_dot.json000066400000000000000000000000061456615046100240170ustar00rootroot00000000000000[.123]orjson-3.9.15/data/parsing/n_number_with_alpha.json000066400000000000000000000000101456615046100223760ustar00rootroot00000000000000[1.2a-3]orjson-3.9.15/data/parsing/n_number_with_alpha_char.json000066400000000000000000000000311456615046100233760ustar00rootroot00000000000000[1.8011670033376514H-308]orjson-3.9.15/data/parsing/n_number_with_leading_zero.json000066400000000000000000000000051456615046100237570ustar00rootroot00000000000000[012]orjson-3.9.15/data/parsing/n_object_bad_value.json000066400000000000000000000000141456615046100221620ustar00rootroot00000000000000["x", truth]orjson-3.9.15/data/parsing/n_object_bracket_key.json000066400000000000000000000000111456615046100225200ustar00rootroot00000000000000{[: "x"} orjson-3.9.15/data/parsing/n_object_comma_instead_of_colon.json000066400000000000000000000000131456615046100247200ustar00rootroot00000000000000{"x", null}orjson-3.9.15/data/parsing/n_object_double_colon.json000066400000000000000000000000121456615046100227020ustar00rootroot00000000000000{"x"::"b"}orjson-3.9.15/data/parsing/n_object_emoji.json000066400000000000000000000000121456615046100213410ustar00rootroot00000000000000{🇨🇭}orjson-3.9.15/data/parsing/n_object_garbage_at_end.json000066400000000000000000000000151456615046100231430ustar00rootroot00000000000000{"a":"a" 123}orjson-3.9.15/data/parsing/n_object_key_with_single_quotes.json000066400000000000000000000000161456615046100250260ustar00rootroot00000000000000{key: 'value'}orjson-3.9.15/data/parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json000066400000000000000000000000121456615046100322350ustar00rootroot00000000000000{"":"0",}orjson-3.9.15/data/parsing/n_object_missing_colon.json000066400000000000000000000000071456615046100231050ustar00rootroot00000000000000{"a" b}orjson-3.9.15/data/parsing/n_object_missing_key.json000066400000000000000000000000061456615046100225620ustar00rootroot00000000000000{:"b"}orjson-3.9.15/data/parsing/n_object_missing_semicolon.json000066400000000000000000000000111456615046100237560ustar00rootroot00000000000000{"a" "b"}orjson-3.9.15/data/parsing/n_object_missing_value.json000066400000000000000000000000051456615046100231050ustar00rootroot00000000000000{"a":orjson-3.9.15/data/parsing/n_object_no-colon.json000066400000000000000000000000041456615046100217630ustar00rootroot00000000000000{"a"orjson-3.9.15/data/parsing/n_object_non_string_key.json000066400000000000000000000000051456615046100232700ustar00rootroot00000000000000{1:1}orjson-3.9.15/data/parsing/n_object_non_string_key_but_huge_number_instead.json000066400000000000000000000000151456615046100302320ustar00rootroot00000000000000{9999E9999:1}orjson-3.9.15/data/parsing/n_object_repeated_null_null.json000066400000000000000000000000251456615046100241170ustar00rootroot00000000000000{null:null,null:null}orjson-3.9.15/data/parsing/n_object_several_trailing_commas.json000066400000000000000000000000151456615046100251320ustar00rootroot00000000000000{"id":0,,,,,}orjson-3.9.15/data/parsing/n_object_single_quote.json000066400000000000000000000000071456615046100227400ustar00rootroot00000000000000{'a':0}orjson-3.9.15/data/parsing/n_object_trailing_comma.json000066400000000000000000000000111456615046100232220ustar00rootroot00000000000000{"id":0,}orjson-3.9.15/data/parsing/n_object_trailing_comment.json000066400000000000000000000000151456615046100235740ustar00rootroot00000000000000{"a":"b"}/**/orjson-3.9.15/data/parsing/n_object_trailing_comment_open.json000066400000000000000000000000161456615046100246160ustar00rootroot00000000000000{"a":"b"}/**//orjson-3.9.15/data/parsing/n_object_trailing_comment_slash_open.json000066400000000000000000000000131456615046100260050ustar00rootroot00000000000000{"a":"b"}//orjson-3.9.15/data/parsing/n_object_trailing_comment_slash_open_incomplete.json000066400000000000000000000000121456615046100302230ustar00rootroot00000000000000{"a":"b"}/orjson-3.9.15/data/parsing/n_object_two_commas_in_a_row.json000066400000000000000000000000221456615046100242640ustar00rootroot00000000000000{"a":"b",,"c":"d"}orjson-3.9.15/data/parsing/n_object_unquoted_key.json000066400000000000000000000000101456615046100227500ustar00rootroot00000000000000{a: "b"}orjson-3.9.15/data/parsing/n_object_unterminated-value.json000066400000000000000000000000071456615046100240530ustar00rootroot00000000000000{"a":"aorjson-3.9.15/data/parsing/n_object_with_single_string.json000066400000000000000000000000261456615046100241450ustar00rootroot00000000000000{ "foo" : "bar", "a" }orjson-3.9.15/data/parsing/n_object_with_trailing_garbage.json000066400000000000000000000000121456615046100245520ustar00rootroot00000000000000{"a":"b"}#orjson-3.9.15/data/parsing/n_single_space.json000066400000000000000000000000011456615046100213420ustar00rootroot00000000000000 orjson-3.9.15/data/parsing/n_string_1_surrogate_then_escape.json000066400000000000000000000000131456615046100250700ustar00rootroot00000000000000["\uD800\"]orjson-3.9.15/data/parsing/n_string_1_surrogate_then_escape_u.json000066400000000000000000000000141456615046100254150ustar00rootroot00000000000000["\uD800\u"]orjson-3.9.15/data/parsing/n_string_1_surrogate_then_escape_u1.json000066400000000000000000000000151456615046100254770ustar00rootroot00000000000000["\uD800\u1"]orjson-3.9.15/data/parsing/n_string_1_surrogate_then_escape_u1x.json000066400000000000000000000000161456615046100256700ustar00rootroot00000000000000["\uD800\u1x"]orjson-3.9.15/data/parsing/n_string_accentuated_char_no_quotes.json000066400000000000000000000000041456615046100256500ustar00rootroot00000000000000[é]orjson-3.9.15/data/parsing/n_string_backslash_00.json000066400000000000000000000000061456615046100225330ustar00rootroot00000000000000["\"]orjson-3.9.15/data/parsing/n_string_escape_x.json000066400000000000000000000000101456615046100220630ustar00rootroot00000000000000["\x00"]orjson-3.9.15/data/parsing/n_string_escaped_backslash_bad.json000066400000000000000000000000071456615046100245270ustar00rootroot00000000000000["\\\"]orjson-3.9.15/data/parsing/n_string_escaped_ctrl_char_tab.json000066400000000000000000000000061456615046100245540ustar00rootroot00000000000000["\ "]orjson-3.9.15/data/parsing/n_string_escaped_emoji.json000066400000000000000000000000111456615046100230640ustar00rootroot00000000000000["\🌀"]orjson-3.9.15/data/parsing/n_string_incomplete_escape.json000066400000000000000000000000051456615046100237570ustar00rootroot00000000000000["\"]orjson-3.9.15/data/parsing/n_string_incomplete_escaped_character.json000066400000000000000000000000111456615046100261340ustar00rootroot00000000000000["\u00A"]orjson-3.9.15/data/parsing/n_string_incomplete_surrogate.json000066400000000000000000000000161456615046100245340ustar00rootroot00000000000000["\uD834\uDd"]orjson-3.9.15/data/parsing/n_string_incomplete_surrogate_escape_invalid.json000066400000000000000000000000221456615046100275570ustar00rootroot00000000000000["\uD800\uD800\x"]orjson-3.9.15/data/parsing/n_string_invalid-utf-8-in-escape.json000066400000000000000000000000071456615046100245330ustar00rootroot00000000000000["\u"]orjson-3.9.15/data/parsing/n_string_invalid_backslash_esc.json000066400000000000000000000000061456615046100245740ustar00rootroot00000000000000["\a"]orjson-3.9.15/data/parsing/n_string_invalid_unicode_escape.json000066400000000000000000000000121456615046100247520ustar00rootroot00000000000000["\uqqqq"]orjson-3.9.15/data/parsing/n_string_invalid_utf8_after_escape.json000066400000000000000000000000061456615046100253760ustar00rootroot00000000000000["\"]orjson-3.9.15/data/parsing/n_string_leading_uescaped_thinspace.json000066400000000000000000000000151456615046100256130ustar00rootroot00000000000000[\u0020"asd"]orjson-3.9.15/data/parsing/n_string_no_quotes_with_bad_escape.json000066400000000000000000000000041456615046100254740ustar00rootroot00000000000000[\n]orjson-3.9.15/data/parsing/n_string_single_doublequote.json000066400000000000000000000000011456615046100241650ustar00rootroot00000000000000"orjson-3.9.15/data/parsing/n_string_single_quote.json000066400000000000000000000000201456615046100227730ustar00rootroot00000000000000['single quote']orjson-3.9.15/data/parsing/n_string_single_string_no_double_quotes.json000066400000000000000000000000031456615046100265730ustar00rootroot00000000000000abcorjson-3.9.15/data/parsing/n_string_start_escape_unclosed.json000066400000000000000000000000031456615046100246470ustar00rootroot00000000000000["\orjson-3.9.15/data/parsing/n_string_unescaped_crtl_char.json000066400000000000000000000000071456615046100242720ustar00rootroot00000000000000["aa"]orjson-3.9.15/data/parsing/n_string_unescaped_newline.json000066400000000000000000000000141456615046100237700ustar00rootroot00000000000000["new line"]orjson-3.9.15/data/parsing/n_string_unescaped_tab.json000066400000000000000000000000051456615046100230750ustar00rootroot00000000000000[" "]orjson-3.9.15/data/parsing/n_string_unicode_CapitalU.json000066400000000000000000000000101456615046100235040ustar00rootroot00000000000000"\UA66D"orjson-3.9.15/data/parsing/n_string_with_trailing_garbage.json000066400000000000000000000000031456615046100246120ustar00rootroot00000000000000""xorjson-3.9.15/data/parsing/n_structure_100000_opening_arrays.json.xz000066400000000000000000000002241456615046100253150ustar00rootroot000000000000007zXZִF!XᆟS]-^?&UhpApLBiqf#M/ #SYuw jtId\Sֱl[CLonQgYZorjson-3.9.15/data/parsing/n_structure_U+2060_word_joined.json000066400000000000000000000000051456615046100242040ustar00rootroot00000000000000[⁠]orjson-3.9.15/data/parsing/n_structure_UTF8_BOM_no_data.json000066400000000000000000000000031456615046100237400ustar00rootroot00000000000000orjson-3.9.15/data/parsing/n_structure_angle_bracket_..json000066400000000000000000000000031456615046100240260ustar00rootroot00000000000000<.>orjson-3.9.15/data/parsing/n_structure_angle_bracket_null.json000066400000000000000000000000101456615046100246410ustar00rootroot00000000000000[]orjson-3.9.15/data/parsing/n_structure_array_trailing_garbage.json000066400000000000000000000000041456615046100255100ustar00rootroot00000000000000[1]xorjson-3.9.15/data/parsing/n_structure_array_with_extra_array_close.json000066400000000000000000000000041456615046100267700ustar00rootroot00000000000000[1]]orjson-3.9.15/data/parsing/n_structure_array_with_unclosed_string.json000066400000000000000000000000061456615046100264660ustar00rootroot00000000000000["asd]orjson-3.9.15/data/parsing/n_structure_ascii-unicode-identifier.json000066400000000000000000000000031456615046100256640ustar00rootroot00000000000000aåorjson-3.9.15/data/parsing/n_structure_capitalized_True.json000066400000000000000000000000061456615046100243230ustar00rootroot00000000000000[True]orjson-3.9.15/data/parsing/n_structure_close_unopened_array.json000066400000000000000000000000021456615046100252270ustar00rootroot000000000000001]orjson-3.9.15/data/parsing/n_structure_comma_instead_of_closing_brace.json000066400000000000000000000000131456615046100271720ustar00rootroot00000000000000{"x": true,orjson-3.9.15/data/parsing/n_structure_double_array.json000066400000000000000000000000041456615046100235010ustar00rootroot00000000000000[][]orjson-3.9.15/data/parsing/n_structure_end_array.json000066400000000000000000000000011456615046100227720ustar00rootroot00000000000000]orjson-3.9.15/data/parsing/n_structure_incomplete_UTF8_BOM.json000066400000000000000000000000041456615046100244730ustar00rootroot00000000000000{}orjson-3.9.15/data/parsing/n_structure_lone-invalid-utf-8.json000066400000000000000000000000011456615046100243500ustar00rootroot00000000000000orjson-3.9.15/data/parsing/n_structure_lone-open-bracket.json000066400000000000000000000000011456615046100243330ustar00rootroot00000000000000[orjson-3.9.15/data/parsing/n_structure_no_data.json000066400000000000000000000000001456615046100224320ustar00rootroot00000000000000orjson-3.9.15/data/parsing/n_structure_null-byte-outside-string.json000066400000000000000000000000031456615046100257210ustar00rootroot00000000000000[]orjson-3.9.15/data/parsing/n_structure_number_with_trailing_garbage.json000066400000000000000000000000021456615046100267130ustar00rootroot000000000000002@orjson-3.9.15/data/parsing/n_structure_object_followed_by_closing_object.json000066400000000000000000000000031456615046100277270ustar00rootroot00000000000000{}}orjson-3.9.15/data/parsing/n_structure_object_unclosed_no_value.json000066400000000000000000000000041456615046100260630ustar00rootroot00000000000000{"":orjson-3.9.15/data/parsing/n_structure_object_with_comment.json000066400000000000000000000000241456615046100250560ustar00rootroot00000000000000{"a":/*comment*/"b"}orjson-3.9.15/data/parsing/n_structure_object_with_trailing_garbage.json000066400000000000000000000000171456615046100266770ustar00rootroot00000000000000{"a": true} "x"orjson-3.9.15/data/parsing/n_structure_open_array_apostrophe.json000066400000000000000000000000021456615046100254320ustar00rootroot00000000000000['orjson-3.9.15/data/parsing/n_structure_open_array_comma.json000066400000000000000000000000021456615046100243420ustar00rootroot00000000000000[,orjson-3.9.15/data/parsing/n_structure_open_array_object.json.xz000066400000000000000000000002601456615046100251620ustar00rootroot000000000000007zXZִF!XАp]-X:t{(5 DG 1CoF͑G〝Z9jlָ'uFʟ*]śWFf=O@O0t>ׇv}n=4%"qz_=WͱgYZorjson-3.9.15/data/parsing/n_structure_open_array_open_object.json000066400000000000000000000000021456615046100255350ustar00rootroot00000000000000[{orjson-3.9.15/data/parsing/n_structure_open_array_open_string.json000066400000000000000000000000031456615046100255760ustar00rootroot00000000000000["aorjson-3.9.15/data/parsing/n_structure_open_array_string.json000066400000000000000000000000041456615046100245560ustar00rootroot00000000000000["a"orjson-3.9.15/data/parsing/n_structure_open_object.json000066400000000000000000000000011456615046100233150ustar00rootroot00000000000000{orjson-3.9.15/data/parsing/n_structure_open_object_close_array.json000066400000000000000000000000021456615046100257010ustar00rootroot00000000000000{]orjson-3.9.15/data/parsing/n_structure_open_object_comma.json000066400000000000000000000000021456615046100244720ustar00rootroot00000000000000{,orjson-3.9.15/data/parsing/n_structure_open_object_open_array.json000066400000000000000000000000021456615046100255350ustar00rootroot00000000000000{[orjson-3.9.15/data/parsing/n_structure_open_object_open_string.json000066400000000000000000000000031456615046100257260ustar00rootroot00000000000000{"aorjson-3.9.15/data/parsing/n_structure_open_object_string_with_apostrophes.json000066400000000000000000000000041456615046100303700ustar00rootroot00000000000000{'a'orjson-3.9.15/data/parsing/n_structure_open_open.json000066400000000000000000000000201456615046100230110ustar00rootroot00000000000000["\{["\{["\{["\{orjson-3.9.15/data/parsing/n_structure_single_eacute.json000066400000000000000000000000011456615046100236350ustar00rootroot00000000000000orjson-3.9.15/data/parsing/n_structure_single_star.json000066400000000000000000000000011456615046100233400ustar00rootroot00000000000000*orjson-3.9.15/data/parsing/n_structure_trailing_#.json000066400000000000000000000000141456615046100230450ustar00rootroot00000000000000{"a":"b"}#{}orjson-3.9.15/data/parsing/n_structure_uescaped_LF_before_string.json000066400000000000000000000000121456615046100261120ustar00rootroot00000000000000[\u000A""]orjson-3.9.15/data/parsing/n_structure_unclosed_array.json000066400000000000000000000000021456615046100240410ustar00rootroot00000000000000[1orjson-3.9.15/data/parsing/n_structure_unclosed_array_partial_null.json000066400000000000000000000000141456615046100266120ustar00rootroot00000000000000[ false, nulorjson-3.9.15/data/parsing/n_structure_unclosed_array_unfinished_false.json000066400000000000000000000000141456615046100274320ustar00rootroot00000000000000[ true, falsorjson-3.9.15/data/parsing/n_structure_unclosed_array_unfinished_true.json000066400000000000000000000000141456615046100273170ustar00rootroot00000000000000[ false, truorjson-3.9.15/data/parsing/n_structure_unclosed_object.json000066400000000000000000000000141456615046100241740ustar00rootroot00000000000000{"asd":"asd"orjson-3.9.15/data/parsing/n_structure_unicode-identifier.json000066400000000000000000000000021456615046100245750ustar00rootroot00000000000000åorjson-3.9.15/data/parsing/n_structure_whitespace_U+2060_word_joiner.json000066400000000000000000000000051456615046100264360ustar00rootroot00000000000000[⁠]orjson-3.9.15/data/parsing/n_structure_whitespace_formfeed.json000066400000000000000000000000031456615046100250330ustar00rootroot00000000000000[ ]orjson-3.9.15/data/parsing/y_array_arraysWithSpaces.json000066400000000000000000000000071456615046100234210ustar00rootroot00000000000000[[] ]orjson-3.9.15/data/parsing/y_array_empty-string.json000066400000000000000000000000041456615046100225640ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/y_array_empty.json000066400000000000000000000000021456615046100212560ustar00rootroot00000000000000[]orjson-3.9.15/data/parsing/y_array_ending_with_newline.json000066400000000000000000000000051456615046100241430ustar00rootroot00000000000000["a"]orjson-3.9.15/data/parsing/y_array_false.json000066400000000000000000000000071456615046100212170ustar00rootroot00000000000000[false]orjson-3.9.15/data/parsing/y_array_heterogeneous.json000066400000000000000000000000221456615046100227760ustar00rootroot00000000000000[null, 1, "1", {}]orjson-3.9.15/data/parsing/y_array_null.json000066400000000000000000000000061456615046100210760ustar00rootroot00000000000000[null]orjson-3.9.15/data/parsing/y_array_with_1_and_newline.json000066400000000000000000000000041456615046100236600ustar00rootroot00000000000000[1 ]orjson-3.9.15/data/parsing/y_array_with_leading_space.json000066400000000000000000000000041456615046100237330ustar00rootroot00000000000000 [1]orjson-3.9.15/data/parsing/y_array_with_several_null.json000066400000000000000000000000241456615046100236520ustar00rootroot00000000000000[1,null,null,null,2]orjson-3.9.15/data/parsing/y_array_with_trailing_space.json000066400000000000000000000000041456615046100241410ustar00rootroot00000000000000[2] orjson-3.9.15/data/parsing/y_number.json000066400000000000000000000000101456615046100202110ustar00rootroot00000000000000[123e65]orjson-3.9.15/data/parsing/y_number_0e+1.json000066400000000000000000000000061456615046100207360ustar00rootroot00000000000000[0e+1]orjson-3.9.15/data/parsing/y_number_0e1.json000066400000000000000000000000051456615046100206620ustar00rootroot00000000000000[0e1]orjson-3.9.15/data/parsing/y_number_after_space.json000066400000000000000000000000041456615046100225500ustar00rootroot00000000000000[ 4]orjson-3.9.15/data/parsing/y_number_double_close_to_zero.json000066400000000000000000000001241456615046100244770ustar00rootroot00000000000000[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] orjson-3.9.15/data/parsing/y_number_int_with_exp.json000066400000000000000000000000061456615046100227770ustar00rootroot00000000000000[20e1]orjson-3.9.15/data/parsing/y_number_minus_zero.json000066400000000000000000000000041456615046100224660ustar00rootroot00000000000000[-0]orjson-3.9.15/data/parsing/y_number_negative_int.json000066400000000000000000000000061456615046100227520ustar00rootroot00000000000000[-123]orjson-3.9.15/data/parsing/y_number_negative_one.json000066400000000000000000000000041456615046100227370ustar00rootroot00000000000000[-1]orjson-3.9.15/data/parsing/y_number_negative_zero.json000066400000000000000000000000041456615046100231350ustar00rootroot00000000000000[-0]orjson-3.9.15/data/parsing/y_number_real_capital_e.json000066400000000000000000000000061456615046100232220ustar00rootroot00000000000000[1E22]orjson-3.9.15/data/parsing/y_number_real_capital_e_neg_exp.json000066400000000000000000000000061456615046100247270ustar00rootroot00000000000000[1E-2]orjson-3.9.15/data/parsing/y_number_real_capital_e_pos_exp.json000066400000000000000000000000061456615046100247570ustar00rootroot00000000000000[1E+2]orjson-3.9.15/data/parsing/y_number_real_exponent.json000066400000000000000000000000101456615046100231340ustar00rootroot00000000000000[123e45]orjson-3.9.15/data/parsing/y_number_real_fraction_exponent.json000066400000000000000000000000141456615046100250250ustar00rootroot00000000000000[123.456e78]orjson-3.9.15/data/parsing/y_number_real_neg_exp.json000066400000000000000000000000061456615046100227260ustar00rootroot00000000000000[1e-2]orjson-3.9.15/data/parsing/y_number_real_pos_exponent.json000066400000000000000000000000061456615046100240220ustar00rootroot00000000000000[1e+2]orjson-3.9.15/data/parsing/y_number_simple_int.json000066400000000000000000000000051456615046100224400ustar00rootroot00000000000000[123]orjson-3.9.15/data/parsing/y_number_simple_real.json000066400000000000000000000000141456615046100225710ustar00rootroot00000000000000[123.456789]orjson-3.9.15/data/parsing/y_object.json000066400000000000000000000000321456615046100201730ustar00rootroot00000000000000{"asd":"sdf", "dfg":"fgh"}orjson-3.9.15/data/parsing/y_object_basic.json000066400000000000000000000000151456615046100213350ustar00rootroot00000000000000{"asd":"sdf"}orjson-3.9.15/data/parsing/y_object_duplicated_key.json000066400000000000000000000000211456615046100232370ustar00rootroot00000000000000{"a":"b","a":"c"}orjson-3.9.15/data/parsing/y_object_duplicated_key_and_value.json000066400000000000000000000000211456615046100252550ustar00rootroot00000000000000{"a":"b","a":"b"}orjson-3.9.15/data/parsing/y_object_empty.json000066400000000000000000000000021456615046100214060ustar00rootroot00000000000000{}orjson-3.9.15/data/parsing/y_object_empty_key.json000066400000000000000000000000061456615046100222620ustar00rootroot00000000000000{"":0}orjson-3.9.15/data/parsing/y_object_escaped_null_in_key.json000066400000000000000000000000241456615046100242500ustar00rootroot00000000000000{"foo\u0000bar": 42}orjson-3.9.15/data/parsing/y_object_extreme_numbers.json000066400000000000000000000000431456615046100234610ustar00rootroot00000000000000{ "min": -1.0e+28, "max": 1.0e+28 }orjson-3.9.15/data/parsing/y_object_long_strings.json000066400000000000000000000001541456615046100227700ustar00rootroot00000000000000{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}orjson-3.9.15/data/parsing/y_object_simple.json000066400000000000000000000000101456615046100215400ustar00rootroot00000000000000{"a":[]}orjson-3.9.15/data/parsing/y_object_string_unicode.json000066400000000000000000000001561456615046100232760ustar00rootroot00000000000000{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" }orjson-3.9.15/data/parsing/y_object_with_newlines.json000066400000000000000000000000141456615046100231320ustar00rootroot00000000000000{ "a": "b" }orjson-3.9.15/data/parsing/y_string_1_2_3_bytes_UTF-8_sequences.json000066400000000000000000000000261456615046100252650ustar00rootroot00000000000000["\u0060\u012a\u12AB"]orjson-3.9.15/data/parsing/y_string_accepted_surrogate_pair.json000066400000000000000000000000201456615046100251660ustar00rootroot00000000000000["\uD801\udc37"]orjson-3.9.15/data/parsing/y_string_accepted_surrogate_pairs.json000066400000000000000000000000341456615046100253560ustar00rootroot00000000000000["\ud83d\ude39\ud83d\udc8d"]orjson-3.9.15/data/parsing/y_string_allowed_escapes.json000066400000000000000000000000241456615046100234460ustar00rootroot00000000000000["\"\\\/\b\f\n\r\t"]orjson-3.9.15/data/parsing/y_string_backslash_and_u_escaped_zero.json000066400000000000000000000000131456615046100261360ustar00rootroot00000000000000["\\u0000"]orjson-3.9.15/data/parsing/y_string_backslash_doublequotes.json000066400000000000000000000000061456615046100250420ustar00rootroot00000000000000["\""]orjson-3.9.15/data/parsing/y_string_comments.json000066400000000000000000000000211456615046100221360ustar00rootroot00000000000000["a/*b*/c/*d//e"]orjson-3.9.15/data/parsing/y_string_double_escape_a.json000066400000000000000000000000071456615046100234070ustar00rootroot00000000000000["\\a"]orjson-3.9.15/data/parsing/y_string_double_escape_n.json000066400000000000000000000000071456615046100234240ustar00rootroot00000000000000["\\n"]orjson-3.9.15/data/parsing/y_string_escaped_control_character.json000066400000000000000000000000121456615046100254710ustar00rootroot00000000000000["\u0012"]orjson-3.9.15/data/parsing/y_string_escaped_noncharacter.json000066400000000000000000000000121456615046100244440ustar00rootroot00000000000000["\uFFFF"]orjson-3.9.15/data/parsing/y_string_in_array.json000066400000000000000000000000071456615046100221210ustar00rootroot00000000000000["asd"]orjson-3.9.15/data/parsing/y_string_in_array_with_leading_space.json000066400000000000000000000000101456615046100260040ustar00rootroot00000000000000[ "asd"]orjson-3.9.15/data/parsing/y_string_last_surrogates_1_and_2.json000066400000000000000000000000201456615046100250140ustar00rootroot00000000000000["\uDBFF\uDFFF"]orjson-3.9.15/data/parsing/y_string_nbsp_uescaped.json000066400000000000000000000000211456615046100231240ustar00rootroot00000000000000["new\u00A0line"]orjson-3.9.15/data/parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json000066400000000000000000000000101456615046100250610ustar00rootroot00000000000000["􏿿"]orjson-3.9.15/data/parsing/y_string_nonCharacterInUTF-8_U+FFFF.json000066400000000000000000000000071456615046100247260ustar00rootroot00000000000000["￿"]orjson-3.9.15/data/parsing/y_string_null_escape.json000066400000000000000000000000121456615046100226030ustar00rootroot00000000000000["\u0000"]orjson-3.9.15/data/parsing/y_string_one-byte-utf-8.json000066400000000000000000000000121456615046100227740ustar00rootroot00000000000000["\u002c"]orjson-3.9.15/data/parsing/y_string_pi.json000066400000000000000000000000061456615046100207240ustar00rootroot00000000000000["π"]orjson-3.9.15/data/parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json000066400000000000000000000000101456615046100260220ustar00rootroot00000000000000["𛿿"]orjson-3.9.15/data/parsing/y_string_simple_ascii.json000066400000000000000000000000101456615046100227500ustar00rootroot00000000000000["asd "]orjson-3.9.15/data/parsing/y_string_space.json000066400000000000000000000000031456615046100214040ustar00rootroot00000000000000" "orjson-3.9.15/data/parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json000066400000000000000000000000201456615046100270020ustar00rootroot00000000000000["\uD834\uDd1e"]orjson-3.9.15/data/parsing/y_string_three-byte-utf-8.json000066400000000000000000000000121456615046100233220ustar00rootroot00000000000000["\u0821"]orjson-3.9.15/data/parsing/y_string_two-byte-utf-8.json000066400000000000000000000000121456615046100230240ustar00rootroot00000000000000["\u0123"]orjson-3.9.15/data/parsing/y_string_u+2028_line_sep.json000066400000000000000000000000071456615046100230260ustar00rootroot00000000000000["
"]orjson-3.9.15/data/parsing/y_string_u+2029_par_sep.json000066400000000000000000000000071456615046100226620ustar00rootroot00000000000000["
"]orjson-3.9.15/data/parsing/y_string_uEscape.json000066400000000000000000000000341456615046100217020ustar00rootroot00000000000000["\u0061\u30af\u30EA\u30b9"]orjson-3.9.15/data/parsing/y_string_uescaped_newline.json000066400000000000000000000000211456615046100236230ustar00rootroot00000000000000["new\u000Aline"]orjson-3.9.15/data/parsing/y_string_unescaped_char_delete.json000066400000000000000000000000051456615046100246010ustar00rootroot00000000000000[""]orjson-3.9.15/data/parsing/y_string_unicode.json000066400000000000000000000000121456615046100217370ustar00rootroot00000000000000["\uA66D"]orjson-3.9.15/data/parsing/y_string_unicodeEscapedBackslash.json000066400000000000000000000000121456615046100250400ustar00rootroot00000000000000["\u005C"]orjson-3.9.15/data/parsing/y_string_unicode_2.json000066400000000000000000000000151456615046100221630ustar00rootroot00000000000000["⍂㈴⍂"]orjson-3.9.15/data/parsing/y_string_unicode_U+10FFFE_nonchar.json000066400000000000000000000000201456615046100245750ustar00rootroot00000000000000["\uDBFF\uDFFE"]orjson-3.9.15/data/parsing/y_string_unicode_U+1FFFE_nonchar.json000066400000000000000000000000201456615046100245150ustar00rootroot00000000000000["\uD83F\uDFFE"]orjson-3.9.15/data/parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json000066400000000000000000000000121456615046100253330ustar00rootroot00000000000000["\u200B"]orjson-3.9.15/data/parsing/y_string_unicode_U+2064_invisible_plus.json000066400000000000000000000000121456615046100257210ustar00rootroot00000000000000["\u2064"]orjson-3.9.15/data/parsing/y_string_unicode_U+FDD0_nonchar.json000066400000000000000000000000121456615046100244040ustar00rootroot00000000000000["\uFDD0"]orjson-3.9.15/data/parsing/y_string_unicode_U+FFFE_nonchar.json000066400000000000000000000000121456615046100244350ustar00rootroot00000000000000["\uFFFE"]orjson-3.9.15/data/parsing/y_string_unicode_escaped_double_quote.json000066400000000000000000000000121456615046100261720ustar00rootroot00000000000000["\u0022"]orjson-3.9.15/data/parsing/y_string_utf8.json000066400000000000000000000000131456615046100212000ustar00rootroot00000000000000["€𝄞"]orjson-3.9.15/data/parsing/y_string_with_del_character.json000066400000000000000000000000071456615046100241300ustar00rootroot00000000000000["aa"]orjson-3.9.15/data/parsing/y_structure_lonely_false.json000066400000000000000000000000051456615046100235210ustar00rootroot00000000000000falseorjson-3.9.15/data/parsing/y_structure_lonely_int.json000066400000000000000000000000021456615046100232160ustar00rootroot0000000000000042orjson-3.9.15/data/parsing/y_structure_lonely_negative_real.json000066400000000000000000000000041456615046100252330ustar00rootroot00000000000000-0.1orjson-3.9.15/data/parsing/y_structure_lonely_null.json000066400000000000000000000000041456615046100234000ustar00rootroot00000000000000nullorjson-3.9.15/data/parsing/y_structure_lonely_string.json000066400000000000000000000000051456615046100237350ustar00rootroot00000000000000"asd"orjson-3.9.15/data/parsing/y_structure_lonely_true.json000066400000000000000000000000041456615046100234050ustar00rootroot00000000000000trueorjson-3.9.15/data/parsing/y_structure_string_empty.json000066400000000000000000000000021456615046100235660ustar00rootroot00000000000000""orjson-3.9.15/data/parsing/y_structure_trailing_newline.json000066400000000000000000000000061456615046100244000ustar00rootroot00000000000000["a"] orjson-3.9.15/data/parsing/y_structure_true_in_array.json000066400000000000000000000000061456615046100237110ustar00rootroot00000000000000[true]orjson-3.9.15/data/parsing/y_structure_whitespace_array.json000066400000000000000000000000041456615046100243760ustar00rootroot00000000000000 [] orjson-3.9.15/data/roundtrip/000077500000000000000000000000001456615046100160725ustar00rootroot00000000000000orjson-3.9.15/data/roundtrip/roundtrip01.json000066400000000000000000000000061456615046100211500ustar00rootroot00000000000000[null]orjson-3.9.15/data/roundtrip/roundtrip02.json000066400000000000000000000000061456615046100211510ustar00rootroot00000000000000[true]orjson-3.9.15/data/roundtrip/roundtrip03.json000066400000000000000000000000071456615046100211530ustar00rootroot00000000000000[false]orjson-3.9.15/data/roundtrip/roundtrip04.json000066400000000000000000000000031456615046100211500ustar00rootroot00000000000000[0]orjson-3.9.15/data/roundtrip/roundtrip05.json000066400000000000000000000000071456615046100211550ustar00rootroot00000000000000["foo"]orjson-3.9.15/data/roundtrip/roundtrip06.json000066400000000000000000000000021456615046100211510ustar00rootroot00000000000000[]orjson-3.9.15/data/roundtrip/roundtrip07.json000066400000000000000000000000021456615046100211520ustar00rootroot00000000000000{}orjson-3.9.15/data/roundtrip/roundtrip08.json000066400000000000000000000000051456615046100211560ustar00rootroot00000000000000[0,1]orjson-3.9.15/data/roundtrip/roundtrip09.json000066400000000000000000000000151456615046100211600ustar00rootroot00000000000000{"foo":"bar"}orjson-3.9.15/data/roundtrip/roundtrip10.json000066400000000000000000000000261456615046100211520ustar00rootroot00000000000000{"a":null,"foo":"bar"}orjson-3.9.15/data/roundtrip/roundtrip11.json000066400000000000000000000000041456615046100211470ustar00rootroot00000000000000[-1]orjson-3.9.15/data/roundtrip/roundtrip12.json000066400000000000000000000000151456615046100211520ustar00rootroot00000000000000[-2147483648]orjson-3.9.15/data/roundtrip/roundtrip13.json000066400000000000000000000000261456615046100211550ustar00rootroot00000000000000[-1234567890123456789]orjson-3.9.15/data/roundtrip/roundtrip14.json000066400000000000000000000000261456615046100211560ustar00rootroot00000000000000[-9223372036854775808]orjson-3.9.15/data/roundtrip/roundtrip15.json000066400000000000000000000000031456615046100211520ustar00rootroot00000000000000[1]orjson-3.9.15/data/roundtrip/roundtrip16.json000066400000000000000000000000141456615046100211550ustar00rootroot00000000000000[2147483647]orjson-3.9.15/data/roundtrip/roundtrip17.json000066400000000000000000000000141456615046100211560ustar00rootroot00000000000000[4294967295]orjson-3.9.15/data/roundtrip/roundtrip18.json000066400000000000000000000000251456615046100211610ustar00rootroot00000000000000[1234567890123456789]orjson-3.9.15/data/roundtrip/roundtrip19.json000066400000000000000000000000251456615046100211620ustar00rootroot00000000000000[9223372036854775807]orjson-3.9.15/data/roundtrip/roundtrip20.json000066400000000000000000000000051456615046100211500ustar00rootroot00000000000000[0.0]orjson-3.9.15/data/roundtrip/roundtrip21.json000066400000000000000000000000061456615046100211520ustar00rootroot00000000000000[-0.0]orjson-3.9.15/data/roundtrip/roundtrip22.json000066400000000000000000000000101456615046100211460ustar00rootroot00000000000000[1.2345]orjson-3.9.15/data/roundtrip/roundtrip23.json000066400000000000000000000000111456615046100211500ustar00rootroot00000000000000[-1.2345]orjson-3.9.15/data/roundtrip/roundtrip24.json000066400000000000000000000000101456615046100211500ustar00rootroot00000000000000[5e-324]orjson-3.9.15/data/roundtrip/roundtrip25.json000066400000000000000000000000301456615046100211530ustar00rootroot00000000000000[2.225073858507201e-308]orjson-3.9.15/data/roundtrip/roundtrip26.json000066400000000000000000000000311456615046100211550ustar00rootroot00000000000000[2.2250738585072014e-308]orjson-3.9.15/data/roundtrip/roundtrip27.json000066400000000000000000000000301456615046100211550ustar00rootroot00000000000000[1.7976931348623157e308]orjson-3.9.15/data/transform/000077500000000000000000000000001456615046100160575ustar00rootroot00000000000000orjson-3.9.15/data/transform/number_1.0.json000066400000000000000000000000051456615046100206130ustar00rootroot00000000000000[1.0]orjson-3.9.15/data/transform/number_1.000000000000000005.json000066400000000000000000000000261456615046100223030ustar00rootroot00000000000000[1.000000000000000005]orjson-3.9.15/data/transform/number_1000000000000000.json000066400000000000000000000000231456615046100217750ustar00rootroot00000000000000[1000000000000000] orjson-3.9.15/data/transform/number_10000000000000000999.json000066400000000000000000000000261456615046100223330ustar00rootroot00000000000000[10000000000000000999]orjson-3.9.15/data/transform/number_1e-999.json000066400000000000000000000000101456615046100211460ustar00rootroot00000000000000[1E-999]orjson-3.9.15/data/transform/number_1e6.json000066400000000000000000000000051456615046100207100ustar00rootroot00000000000000[1E6]orjson-3.9.15/data/transform/object_key_nfc_nfd.json000066400000000000000000000000301456615046100225360ustar00rootroot00000000000000{"é":"NFC","é":"NFD"}orjson-3.9.15/data/transform/object_key_nfd_nfc.json000066400000000000000000000000301456615046100225360ustar00rootroot00000000000000{"é":"NFD","é":"NFC"}orjson-3.9.15/data/transform/object_same_key_different_values.json000066400000000000000000000000151456615046100254760ustar00rootroot00000000000000{"a":1,"a":2}orjson-3.9.15/data/transform/object_same_key_same_value.json000066400000000000000000000000151456615046100242720ustar00rootroot00000000000000{"a":1,"a":1}orjson-3.9.15/data/transform/object_same_key_unclear_values.json000066400000000000000000000000201456615046100251550ustar00rootroot00000000000000{"a":0, "a":-0} orjson-3.9.15/data/transform/string_1_escaped_invalid_codepoint.json000066400000000000000000000000121456615046100257270ustar00rootroot00000000000000["\uD800"]orjson-3.9.15/data/transform/string_1_invalid_codepoint.json000066400000000000000000000000071456615046100242470ustar00rootroot00000000000000[""]orjson-3.9.15/data/transform/string_2_escaped_invalid_codepoints.json000066400000000000000000000000201456615046100261120ustar00rootroot00000000000000["\uD800\uD800"]orjson-3.9.15/data/transform/string_2_invalid_codepoints.json000066400000000000000000000000121456615046100244270ustar00rootroot00000000000000[""]orjson-3.9.15/data/transform/string_3_escaped_invalid_codepoints.json000066400000000000000000000000261456615046100261210ustar00rootroot00000000000000["\uD800\uD800\uD800"]orjson-3.9.15/data/transform/string_3_invalid_codepoints.json000066400000000000000000000000151456615046100244330ustar00rootroot00000000000000[""]orjson-3.9.15/data/transform/string_with_escaped_NULL.json000066400000000000000000000000141456615046100236240ustar00rootroot00000000000000["A\u0000B"]orjson-3.9.15/data/twitter.json.xz000066400000000000000000001037341456615046100171110ustar00rootroot000000000000007zXZִF!Xه]=1)x k u ;[wm[>|a88tB3\phF(~;Kf^sDBXB&* /G{_ڏ3ŵQZdLOPVrˣ~*N{eYWYNY RbQjm E+MG_`ӌ ϫ]hma`f֗,5t~5JMtH/voC>dH b1<'ӼG%@@GB^=X/ij_tig'!¯t\%1[(4]m sPv]Yݭ @ժr2"D8&sI_<_\àV)l{ǣq Sn` sU4ᨶwAZurFז-j c]Og`EB7'5Kz8ɏU-z_5?8+d{gR}75s@ta}拼 F̨ZP AꀾPu I&%$k$Ig]l.Gm(+O{1Um3X%M BcG?CҁPP#b "`:LxPǫq<8_nset12jt, YEFaCYG3\jTM릑}ʱv.z #?cLQN,U!\KryWF*{[8UAR,3(ʣ=R~ F `~;s=,҂=H8^^bl"-3 <(&άnHQi)FR0NluaKǦD(ek^.3J4O?ķd2̊uں=0 '4pK֍A3 o'5#~b`E>dڳ6,A%_xg}<( g4n SۣS3C ԙ$wώ'TCC"j'o$ܯ<(͡AlWcǠH%Ry*^wԿg/Ol9xH 1By8=y Q [YEQ'GI d{:!m$jkvs.;J)ɃYá; D_ t'zV ͡ oxLt 6{nɪG5 W#d_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<'{YT&O:ll" #ZîmƞX&F aoxryPsTҶziقwrMDɲ.)Q=Dp8 `pzMM\H y9v+ HblzGiOo@x򚜀1OT[kt1Hۈyԍ+ݪq韴nzzCYҐ{J",`+"8 T.co:եqÿ8 R/SP TsӤq2]~H-/ !UߦEq뽣(C>W8I]ӶRUyֳuɷާ?9ZJH.@ӎEidi\l0vigpu_).~9M>ڳSvѰ5>n 56u"㼜- CT*H1,{s9J{2d)Vy9d;d?T6Rrcq8c*5W@@e$ ֏8㗡}ob0O]+TR-24ou-˨opv+pM>ud+wA3A1DeGqRE\ҌL]-8ؿФߔ#&kƪⱂE L&I^X u.hϫhM 63%HinpĦhJ 9d R]OvPX'^HD#Ƅ%c`{kyJٝyRG댮)_nQśwM\;2mw%X(r##w0:\&)QAWy3㿾W{5)j-E­)](P~/sf2HD%Zq7z-#ܴ9"}>w+#gT mc5y j5ǎ\kKj>fTt^ʉpS=搈Ce0*,yy#oۻ٤@n՟iuԝ?=je.d9 ¸.g??TmLsMMY62)opxwއ1z0[v)qyYղv*!+@MY'by?!Ę&PhY^>~SoT^ U@l@:,; FCEIg.ދgs*oRx: ,zYbaiZQCG<CL>88JxV؛8 ۖ3E.7ըͧ]0q+ڛ˴D(:Rſak.CL̦Ja` [-}#q'c?q@H ,`A\/bcͮXT9ﭾʝTCF08\O? R]&6&ïsgYZorjson-3.9.15/doc/000077500000000000000000000000001456615046100137005ustar00rootroot00000000000000orjson-3.9.15/doc/deserialization.png000066400000000000000000004001211456615046100175720ustar00rootroot00000000000000PNG  IHDR^9tEXtSoftwareMatplotlib version3.8.2, https://matplotlib.org/ pHYs.#.#x?vIDATxwxվ{RHH.ESbAnD&[Q R Q^BT˼2'2&:֬lGfY208 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$Ip7oVݺu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orjson-3.9.15/doc/serialization.png000066400000000000000000004066141456615046100172760ustar00rootroot00000000000000PNG  IHDR^9tEXtSoftwareMatplotlib version3.8.2, https://matplotlib.org/ pHYs.#.#x?vIDATxwtTg; H"]P;" *˽"  ("(; {J He?x9LXw]~g.̓l6(\]t 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N08 `p$I 'A N0.=5jdc9B>}PoF4o޼2}V5xI v7oՑͧOvtY '̙3]QF ?.B6l 2)p08 `p$x0***JJOOTjUv-Ҵk.… JKKS``*Wƍf͚Oagh2->tP 6̪O?g}flrٚ7o,X;w{Z4kL={#<")Ffff͚N]Wz C [|ƍ .<'''Gjٲe68VҤIt Ɵ%''DO?咓5n8hTtQ˥iܸq3fL)VU8p7=3ꫯJ+oܹ8pMo^QQQ6lױ{n=Eرc?x@v17b///]wujѢ㣜%''ܹs:|SѮ3f~'@uY͚5S*U奤$>|XUO?_/-iڽ{]Z5uU 6T*UHQe!<<\M4QUzuK:{8u)))0ojذUw'7n\59bϯS7nzjժRRRkJOO1԰aCuڵCCC-חhՓ{ `9Ҫd2kU.]*WWW9sFՑfYL& P:bbb4i$K :cǎ^<==uYmڴIk׮! &sΪQFKTXӦMSffW^1bMϚ=rVXaӝ{sε  /wwl֪U4f?_]v曋r111ZdA /~8WFF]aÆ۷n&ծ]񙙙駟Gt}wԣGU^T+իk…Şwi@ժU9&I[}ݧ.]($$}RRR4}tM2i٬#Fh͚5w޳>g}V4o<1W_}u'N7ްoذƏ-[Z7h =zT#GΝ; }СZhaw-SLyҥF2dHRSSW_iܸqv hnh_wu4iM$կ__CիUfǝ>}ZovZp|_bw-hܹVourQ.u㣯Z kտ-^Xl %C=~Y333?Zm|rM0)S(44y#GٳJJnn\ J`;oTC_5k֬|KիN]w?+++߻mq)}_{qƚ1cUؾtRk@l<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""""""""z&e] s BeK˺DDDDd%&"""""""g25ʴ.ٹuȊph""""""""""""""+0`J0LDDDDDDDDDDDDDd%&""""""""""""" Y DDDDDDDDDDDDDDV`""""""""""""""+0`J0LDDDDDDDDDDDDDd%&""""""""""""" Y DDDDDDDDDDDDDDV`""""""""""""""+0`J0LDDDDDDDDDDDDDd%&""""""""""""" Y DDDDDDDDDDDDDDV`""""""""""""""+0`Jؕu\t =R;BBBШQ#888{1118s ?~ '''iӦ/222vZj@=PBb40LbXlu~.]O>bڴi>ѣѣG˻tRf͚a&oqh(BcO>,lذoΜ9#i۷oFϞ=u 55SLٳM*۷~z&OlDDDDDDDDDDDDDe`J#Gbǎ嶶\2j׮ 777g)))8p Ο?op FBRR\(oTTv-3g΄R5k֔.QYb,f8phYϞ=q!8pN>%K @ȓ#GӧzƍBK.8z(mۆ`ڵ>;w.T*2ݻǎbĈ1LXBl̘16me666xW/ 00PX#DEE֭[ׯ_3g΄E믅t\\N8a999njC#9rqFԫWOXvB/TlTeSp6IK*"KωY\7Da}s"z֔F77.Qb`2+͡[Na/]MsEw[vvv={(ӧ aÆi =g"%%... AddV3""E u`}NDdXYDdV B&o^|8 {!99NNNR ܴ򧤤4i38p>SV*Xbbcc1o  7oՅj뼼"""""""""""""K`,-7oNaJѳgO +T{+VG[Fdduv*ܹs4ie{ٳtHH7n\2Lml\^bRT:t(:$Znkk!66?;z}P(رc:FJJ >|(ʿrJK*#%0Y -ZzK.^(J#445C}v"""ЬYboݻ8wիI&%.'%0LDDDDDDDDDDDDDd%80`J0LDDDDDDDDDDDDDd%&""""""""""""" Y DDDDDDDDDDDDDDV`""""""""""""""+0`J0LDDDDDDDDDDDDDd%&"z|xt:uJʺHDd!]|`YZy/m&*߶mʺHD%VwDsibccE &ui۶PGm۶Sl&Lwe]$"r`""""""""""""""+0`8$9!,îѳC>8t&`""""""""""""""+aW ""֯__ExEDDƍe] "*o[.]ХK.Y>Ure0{l̞=ADLa`""""""""""""""+0`Jp`""*5 /^D\\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z5>>^wrtt4̱WHH_|aӦMC]999h^S>} @ۮa^z/=ڰaCS0uTCfeff6R7 wJƍ 4>`q5zhk[֪U,{'UV:99Yoffff*::0gСҥK۶mg}0;五+>>?^lYE/+++˪0 <\SjjϨTllbbbFhsUU8Ј@ow&99b'nyy %&&ԩS5۷תUu:tYfi…۷^{5<^TT{j5iuK/믿VBB׿ɓ'o߾jѢy~EERRRtAڵK;w觞zJ+V0)))2e,X`\ZZ#GhʕJMM<<(++Ko- 3g***8&l4=:~+GGG[nٳgSTT'NUeeڴiN:)((H:t3ti>}:($$ΣmYyyt%檸X[~)00P...&6F``#F A 6l0``#F A 6l0``#F A 6l0``#F A 6l0``#A<dIENDB`orjson-3.9.15/include/000077500000000000000000000000001456615046100145565ustar00rootroot00000000000000orjson-3.9.15/include/yyjson-recursion-limit.patch000066400000000000000000000124351456615046100222620ustar00rootroot00000000000000diff --git a/include/yyjson/yyjson.c b/include/yyjson/yyjson.c index e76f538..4bac033 100644 --- a/include/yyjson/yyjson.c +++ b/include/yyjson/yyjson.c @@ -329,8 +329,9 @@ uint32_t yyjson_version(void) { #ifndef YYJSON_DISABLE_UTF8_VALIDATION #define YYJSON_DISABLE_UTF8_VALIDATION 0 #endif - - +#ifndef YYJSON_READER_CONTAINER_RECURSION_LIMIT +#define YYJSON_READER_CONTAINER_RECURSION_LIMIT 1024 +#endif /*============================================================================== * Macros @@ -5798,6 +5799,8 @@ fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); +fail_recursion: + return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef return_err } @@ -5854,7 +5857,8 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ - + + u32 container_depth = 0; /* limit on number of open array and map */ bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ @@ -5889,6 +5893,11 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, } arr_begin: + container_depth++; + if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { + goto fail_recursion; + } + /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); @@ -5988,6 +5997,8 @@ arr_val_end: goto fail_character; arr_end: + container_depth--; + /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); @@ -6006,6 +6017,11 @@ arr_end: } obj_begin: + container_depth++; + if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { + goto fail_recursion; + } + /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); @@ -6134,6 +6150,8 @@ obj_val_end: goto fail_character; obj_end: + container_depth--; + /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* point to the next value */ @@ -6185,6 +6203,8 @@ fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); +fail_recursion: + return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef val_incr #undef return_err @@ -6242,7 +6262,8 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ - + + u32 container_depth = 0; /* limit on number of open array and map */ bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ @@ -6279,6 +6300,11 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, } arr_begin: + container_depth++; + if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { + goto fail_recursion; + } + /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); @@ -6395,6 +6421,8 @@ arr_val_end: goto fail_character; arr_end: + container_depth--; + /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); @@ -6414,6 +6442,11 @@ arr_end: } obj_begin: + container_depth++; + if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { + goto fail_recursion; + } + /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); @@ -6562,6 +6595,8 @@ obj_val_end: goto fail_character; obj_end: + container_depth--; + /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* point to the next value */ @@ -6614,6 +6649,8 @@ fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); +fail_recursion: + return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef val_incr #undef return_err diff --git a/include/yyjson/yyjson.h b/include/yyjson/yyjson.h index c393408..bc688e0 100644 --- a/include/yyjson/yyjson.h +++ b/include/yyjson/yyjson.h @@ -831,6 +831,9 @@ static const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12; /** Failed to read a file. */ static const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13; +/** Document exceeded YYJSON_READER_CONTAINER_RECURSION_LIMIT. */ +static const yyjson_read_code YYJSON_READ_ERROR_RECURSION_DEPTH = 14; + /** Error information for JSON reader. */ typedef struct yyjson_read_err { /** Error code, see `yyjson_read_code` for all possible values. */ orjson-3.9.15/include/yyjson/000077500000000000000000000000001456615046100161115ustar00rootroot00000000000000orjson-3.9.15/include/yyjson/yyjson.c000066400000000000000000012643771456615046100176340ustar00rootroot00000000000000/*============================================================================== Copyright (c) 2020 YaoYuan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *============================================================================*/ #include "yyjson.h" #include /*============================================================================== * Warning Suppress *============================================================================*/ #if defined(__clang__) # pragma clang diagnostic ignored "-Wunused-function" # pragma clang diagnostic ignored "-Wunused-parameter" # pragma clang diagnostic ignored "-Wunused-label" # pragma clang diagnostic ignored "-Wunused-macros" # pragma clang diagnostic ignored "-Wunused-variable" #elif defined(__GNUC__) # pragma GCC diagnostic ignored "-Wunused-function" # pragma GCC diagnostic ignored "-Wunused-parameter" # pragma GCC diagnostic ignored "-Wunused-label" # pragma GCC diagnostic ignored "-Wunused-macros" # pragma GCC diagnostic ignored "-Wunused-variable" #elif defined(_MSC_VER) # pragma warning(disable:4100) /* unreferenced formal parameter */ # pragma warning(disable:4101) /* unreferenced variable */ # pragma warning(disable:4102) /* unreferenced label */ # pragma warning(disable:4127) /* conditional expression is constant */ # pragma warning(disable:4706) /* assignment within conditional expression */ #endif /*============================================================================== * Version *============================================================================*/ uint32_t yyjson_version(void) { return YYJSON_VERSION_HEX; } /*============================================================================== * Flags *============================================================================*/ /* msvc intrinsic */ #if YYJSON_MSC_VER >= 1400 # include # if defined(_M_AMD64) || defined(_M_ARM64) # define MSC_HAS_BIT_SCAN_64 1 # pragma intrinsic(_BitScanForward64) # pragma intrinsic(_BitScanReverse64) # else # define MSC_HAS_BIT_SCAN_64 0 # endif # if defined(_M_AMD64) || defined(_M_ARM64) || \ defined(_M_IX86) || defined(_M_ARM) # define MSC_HAS_BIT_SCAN 1 # pragma intrinsic(_BitScanForward) # pragma intrinsic(_BitScanReverse) # else # define MSC_HAS_BIT_SCAN 0 # endif # if defined(_M_AMD64) # define MSC_HAS_UMUL128 1 # pragma intrinsic(_umul128) # else # define MSC_HAS_UMUL128 0 # endif #else # define MSC_HAS_BIT_SCAN_64 0 # define MSC_HAS_BIT_SCAN 0 # define MSC_HAS_UMUL128 0 #endif /* gcc builtin */ #if yyjson_has_builtin(__builtin_clzll) || yyjson_gcc_available(3, 4, 0) # define GCC_HAS_CLZLL 1 #else # define GCC_HAS_CLZLL 0 #endif #if yyjson_has_builtin(__builtin_ctzll) || yyjson_gcc_available(3, 4, 0) # define GCC_HAS_CTZLL 1 #else # define GCC_HAS_CTZLL 0 #endif /* int128 type */ #if defined(__SIZEOF_INT128__) && (__SIZEOF_INT128__ == 16) && \ (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)) # define YYJSON_HAS_INT128 1 #else # define YYJSON_HAS_INT128 0 #endif /* IEEE 754 floating-point binary representation */ #if defined(__STDC_IEC_559__) || defined(__STDC_IEC_60559_BFP__) # define YYJSON_HAS_IEEE_754 1 #elif (FLT_RADIX == 2) && (DBL_MANT_DIG == 53) && (DBL_DIG == 15) && \ (DBL_MIN_EXP == -1021) && (DBL_MAX_EXP == 1024) && \ (DBL_MIN_10_EXP == -307) && (DBL_MAX_10_EXP == 308) # define YYJSON_HAS_IEEE_754 1 #else # define YYJSON_HAS_IEEE_754 0 #endif /* Correct rounding in double number computations. On the x86 architecture, some compilers may use x87 FPU instructions for floating-point arithmetic. The x87 FPU loads all floating point number as 80-bit double-extended precision internally, then rounds the result to original precision, which may produce inaccurate results. For a more detailed explanation, see the paper: https://arxiv.org/abs/cs/0701192 Here are some examples of double precision calculation error: 2877.0 / 1e6 == 0.002877, but x87 returns 0.0028770000000000002 43683.0 * 1e21 == 4.3683e25, but x87 returns 4.3683000000000004e25 Here are some examples of compiler flags to generate x87 instructions on x86: clang -m32 -mno-sse gcc/icc -m32 -mfpmath=387 msvc /arch:SSE or /arch:IA32 If we are sure that there's no similar error described above, we can define the YYJSON_DOUBLE_MATH_CORRECT as 1 to enable the fast path calculation. This is not an accurate detection, it's just try to avoid the error at compile-time. An accurate detection can be done at run-time: bool is_double_math_correct(void) { volatile double r = 43683.0; r *= 1e21; return r == 4.3683e25; } See also: utils.h in https://github.com/google/double-conversion/ */ #if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__) # define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #endif #if defined(FLT_EVAL_METHOD) && FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1 # define YYJSON_DOUBLE_MATH_CORRECT 0 #elif defined(i386) || defined(__i386) || defined(__i386__) || \ defined(_X86_) || defined(__X86__) || defined(_M_IX86) || \ defined(__I86__) || defined(__IA32__) || defined(__THW_INTEL) # if (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP == 2) || \ (defined(__SSE2_MATH__) && __SSE2_MATH__) # define YYJSON_DOUBLE_MATH_CORRECT 1 # else # define YYJSON_DOUBLE_MATH_CORRECT 0 # endif #elif defined(__mc68000__) || defined(__pnacl__) || defined(__native_client__) # define YYJSON_DOUBLE_MATH_CORRECT 0 #else # define YYJSON_DOUBLE_MATH_CORRECT 1 #endif /* endian */ #if yyjson_has_include() # include /* POSIX */ #endif #if yyjson_has_include() # include /* Linux */ #elif yyjson_has_include() # include /* BSD, Android */ #elif yyjson_has_include() # include /* BSD, Darwin */ #endif #define YYJSON_BIG_ENDIAN 4321 #define YYJSON_LITTLE_ENDIAN 1234 #if defined(BYTE_ORDER) && BYTE_ORDER # if defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) # define YYJSON_ENDIAN YYJSON_BIG_ENDIAN # elif defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN) # define YYJSON_ENDIAN YYJSON_LITTLE_ENDIAN # endif #elif defined(__BYTE_ORDER) && __BYTE_ORDER # if defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) # define YYJSON_ENDIAN YYJSON_BIG_ENDIAN # elif defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) # define YYJSON_ENDIAN YYJSON_LITTLE_ENDIAN # endif #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ # if defined(__ORDER_BIG_ENDIAN__) && \ (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) # define YYJSON_ENDIAN YYJSON_BIG_ENDIAN # elif defined(__ORDER_LITTLE_ENDIAN__) && \ (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) # define YYJSON_ENDIAN YYJSON_LITTLE_ENDIAN # endif #elif (defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__ == 1) || \ defined(__i386) || defined(__i386__) || \ defined(_X86_) || defined(__X86__) || \ defined(_M_IX86) || defined(__THW_INTEL__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(__amd64) || defined(__amd64__) || \ defined(_M_AMD64) || defined(_M_X64) || \ defined(_M_ARM) || defined(_M_ARM64) || \ defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \ defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || \ defined(__EMSCRIPTEN__) || defined(__wasm__) || \ defined(__loongarch__) # define YYJSON_ENDIAN YYJSON_LITTLE_ENDIAN #elif (defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ == 1) || \ defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || \ defined(__or1k__) || defined(__OR1K__) # define YYJSON_ENDIAN YYJSON_BIG_ENDIAN #else # define YYJSON_ENDIAN 0 /* unknown endian, detect at run-time */ #endif /* This macro controls how yyjson handles unaligned memory accesses. By default, yyjson uses `memcpy()` for memory copying. This takes advantage of the compiler's automatic optimizations to generate unaligned memory access instructions when the target architecture supports it. However, for some older compilers or architectures where `memcpy()` isn't optimized well and may generate unnecessary function calls, consider defining this macro as 1. In such cases, yyjson switches to manual byte-by-byte access, potentially improving performance. An example of the generated assembly code on the ARM platform can be found here: https://godbolt.org/z/334jjhxPT As this flag has already been enabled for some common architectures in the following code, users typically don't need to manually specify it. If users are unsure about it, please review the generated assembly code or perform actual benchmark to make an informed decision. */ #ifndef YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS # if defined(__ia64) || defined(_IA64) || defined(__IA64__) || \ defined(__ia64__) || defined(_M_IA64) || defined(__itanium__) # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 1 /* Itanium */ # elif (defined(__arm__) || defined(__arm64__) || defined(__aarch64__)) && \ (defined(__GNUC__) || defined(__clang__)) && \ (!defined(__ARM_FEATURE_UNALIGNED) || !__ARM_FEATURE_UNALIGNED) # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 1 /* ARM */ # elif defined(__sparc) || defined(__sparc__) # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 1 /* SPARC */ # elif defined(__mips) || defined(__mips__) || defined(__MIPS__) # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 1 /* MIPS */ # elif defined(__m68k__) || defined(M68000) # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 1 /* M68K */ # else # define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 0 # endif #endif /* Estimated initial ratio of the JSON data (data_size / value_count). For example: data: {"id":12345678,"name":"Harry"} data_size: 30 value_count: 5 ratio: 6 yyjson uses dynamic memory with a growth factor of 1.5 when reading and writing JSON, the ratios below are used to determine the initial memory size. A too large ratio will waste memory, and a too small ratio will cause multiple memory growths and degrade performance. Currently, these ratios are generated with some commonly used JSON datasets. */ #define YYJSON_READER_ESTIMATED_PRETTY_RATIO 16 #define YYJSON_READER_ESTIMATED_MINIFY_RATIO 6 #define YYJSON_WRITER_ESTIMATED_PRETTY_RATIO 32 #define YYJSON_WRITER_ESTIMATED_MINIFY_RATIO 18 /* The initial and maximum size of the memory pool's chunk in yyjson_mut_doc. */ #define YYJSON_MUT_DOC_STR_POOL_INIT_SIZE 0x100 #define YYJSON_MUT_DOC_STR_POOL_MAX_SIZE 0x10000000 #define YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE (0x10 * sizeof(yyjson_mut_val)) #define YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE (0x1000000 * sizeof(yyjson_mut_val)) /* The minimum size of the dynamic allocator's chunk. */ #define YYJSON_ALC_DYN_MIN_SIZE 0x1000 /* Default value for compile-time options. */ #ifndef YYJSON_DISABLE_READER #define YYJSON_DISABLE_READER 0 #endif #ifndef YYJSON_DISABLE_WRITER #define YYJSON_DISABLE_WRITER 0 #endif #ifndef YYJSON_DISABLE_UTILS #define YYJSON_DISABLE_UTILS 0 #endif #ifndef YYJSON_DISABLE_FAST_FP_CONV #define YYJSON_DISABLE_FAST_FP_CONV 0 #endif #ifndef YYJSON_DISABLE_NON_STANDARD #define YYJSON_DISABLE_NON_STANDARD 0 #endif #ifndef YYJSON_DISABLE_UTF8_VALIDATION #define YYJSON_DISABLE_UTF8_VALIDATION 0 #endif #ifndef YYJSON_READER_CONTAINER_RECURSION_LIMIT #define YYJSON_READER_CONTAINER_RECURSION_LIMIT 1024 #endif /*============================================================================== * Macros *============================================================================*/ /* Macros used for loop unrolling and other purpose. */ #define repeat2(x) { x x } #define repeat3(x) { x x x } #define repeat4(x) { x x x x } #define repeat8(x) { x x x x x x x x } #define repeat16(x) { x x x x x x x x x x x x x x x x } #define repeat2_incr(x) { x(0) x(1) } #define repeat4_incr(x) { x(0) x(1) x(2) x(3) } #define repeat8_incr(x) { x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) } #define repeat16_incr(x) { x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) \ x(8) x(9) x(10) x(11) x(12) x(13) x(14) x(15) } #define repeat_in_1_18(x) { x(1) x(2) x(3) x(4) x(5) x(6) x(7) x(8) \ x(9) x(10) x(11) x(12) x(13) x(14) x(15) x(16) \ x(17) x(18) } /* Macros used to provide branch prediction information for compiler. */ #undef likely #define likely(x) yyjson_likely(x) #undef unlikely #define unlikely(x) yyjson_unlikely(x) /* Macros used to provide inline information for compiler. */ #undef static_inline #define static_inline static yyjson_inline #undef static_noinline #define static_noinline static yyjson_noinline /* Macros for min and max. */ #undef yyjson_min #define yyjson_min(x, y) ((x) < (y) ? (x) : (y)) #undef yyjson_max #define yyjson_max(x, y) ((x) > (y) ? (x) : (y)) /* Used to write u64 literal for C89 which doesn't support "ULL" suffix. */ #undef U64 #define U64(hi, lo) ((((u64)hi##UL) << 32U) + lo##UL) /* Used to cast away (remove) const qualifier. */ #define constcast(type) (type)(void *)(size_t)(const void *) /* flag test */ #define has_read_flag(_flag) false #define has_write_flag(_flag) unlikely(write_flag_eq(flg, YYJSON_WRITE_##_flag)) static_inline bool read_flag_eq(yyjson_read_flag flg, yyjson_read_flag chk) { #if YYJSON_DISABLE_NON_STANDARD if (chk == YYJSON_READ_ALLOW_INF_AND_NAN || chk == YYJSON_READ_ALLOW_COMMENTS || chk == YYJSON_READ_ALLOW_TRAILING_COMMAS || chk == YYJSON_READ_ALLOW_INVALID_UNICODE) return false; /* this should be evaluated at compile-time */ #endif return (flg & chk) != 0; } static_inline bool write_flag_eq(yyjson_write_flag flg, yyjson_write_flag chk) { #if YYJSON_DISABLE_NON_STANDARD if (chk == YYJSON_WRITE_ALLOW_INF_AND_NAN || chk == YYJSON_WRITE_ALLOW_INVALID_UNICODE) return false; /* this should be evaluated at compile-time */ #endif return (flg & chk) != 0; } /*============================================================================== * Integer Constants *============================================================================*/ /* U64 constant values */ #undef U64_MAX #define U64_MAX U64(0xFFFFFFFF, 0xFFFFFFFF) #undef I64_MAX #define I64_MAX U64(0x7FFFFFFF, 0xFFFFFFFF) #undef USIZE_MAX #define USIZE_MAX ((usize)(~(usize)0)) /* Maximum number of digits for reading u32/u64/usize safety (not overflow). */ #undef U32_SAFE_DIG #define U32_SAFE_DIG 9 /* u32 max is 4294967295, 10 digits */ #undef U64_SAFE_DIG #define U64_SAFE_DIG 19 /* u64 max is 18446744073709551615, 20 digits */ #undef USIZE_SAFE_DIG #define USIZE_SAFE_DIG (sizeof(usize) == 8 ? U64_SAFE_DIG : U32_SAFE_DIG) /*============================================================================== * IEEE-754 Double Number Constants *============================================================================*/ /* Inf raw value (positive) */ #define F64_RAW_INF U64(0x7FF00000, 0x00000000) /* NaN raw value (quiet NaN, no payload, no sign) */ #if defined(__hppa__) || (defined(__mips__) && !defined(__mips_nan2008)) #define F64_RAW_NAN U64(0x7FF7FFFF, 0xFFFFFFFF) #else #define F64_RAW_NAN U64(0x7FF80000, 0x00000000) #endif /* double number bits */ #define F64_BITS 64 /* double number exponent part bits */ #define F64_EXP_BITS 11 /* double number significand part bits */ #define F64_SIG_BITS 52 /* double number significand part bits (with 1 hidden bit) */ #define F64_SIG_FULL_BITS 53 /* double number significand bit mask */ #define F64_SIG_MASK U64(0x000FFFFF, 0xFFFFFFFF) /* double number exponent bit mask */ #define F64_EXP_MASK U64(0x7FF00000, 0x00000000) /* double number exponent bias */ #define F64_EXP_BIAS 1023 /* double number significant digits count in decimal */ #define F64_DEC_DIG 17 /* max significant digits count in decimal when reading double number */ #define F64_MAX_DEC_DIG 768 /* maximum decimal power of double number (1.7976931348623157e308) */ #define F64_MAX_DEC_EXP 308 /* minimum decimal power of double number (4.9406564584124654e-324) */ #define F64_MIN_DEC_EXP (-324) /* maximum binary power of double number */ #define F64_MAX_BIN_EXP 1024 /* minimum binary power of double number */ #define F64_MIN_BIN_EXP (-1021) /*============================================================================== * Types *============================================================================*/ /** Type define for primitive types. */ typedef float f32; typedef double f64; typedef int8_t i8; typedef uint8_t u8; typedef int16_t i16; typedef uint16_t u16; typedef int32_t i32; typedef uint32_t u32; typedef int64_t i64; typedef uint64_t u64; typedef size_t usize; /** 128-bit integer, used by floating-point number reader and writer. */ #if YYJSON_HAS_INT128 __extension__ typedef __int128 i128; __extension__ typedef unsigned __int128 u128; #endif /** 16/32/64-bit vector */ typedef struct v16 { char c[2]; } v16; typedef struct v32 { char c[4]; } v32; typedef struct v64 { char c[8]; } v64; /** 16/32/64-bit vector union */ typedef union v16_uni { v16 v; u16 u; } v16_uni; typedef union v32_uni { v32 v; u32 u; } v32_uni; typedef union v64_uni { v64 v; u64 u; } v64_uni; /*============================================================================== * Load/Store Utils *============================================================================*/ #if YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS #define byte_move_idx(x) ((char *)dst)[x] = ((const char *)src)[x]; static_inline void byte_copy_2(void *dst, const void *src) { repeat2_incr(byte_move_idx) } static_inline void byte_copy_4(void *dst, const void *src) { repeat4_incr(byte_move_idx) } static_inline void byte_copy_8(void *dst, const void *src) { repeat8_incr(byte_move_idx) } static_inline void byte_copy_16(void *dst, const void *src) { repeat16_incr(byte_move_idx) } static_inline void byte_move_2(void *dst, const void *src) { repeat2_incr(byte_move_idx) } static_inline void byte_move_4(void *dst, const void *src) { repeat4_incr(byte_move_idx) } static_inline void byte_move_8(void *dst, const void *src) { repeat8_incr(byte_move_idx) } static_inline void byte_move_16(void *dst, const void *src) { repeat16_incr(byte_move_idx) } static_inline bool byte_match_2(void *buf, const char *pat) { return ((char *)buf)[0] == ((const char *)pat)[0] && ((char *)buf)[1] == ((const char *)pat)[1]; } static_inline bool byte_match_4(void *buf, const char *pat) { return ((char *)buf)[0] == ((const char *)pat)[0] && ((char *)buf)[1] == ((const char *)pat)[1] && ((char *)buf)[2] == ((const char *)pat)[2] && ((char *)buf)[3] == ((const char *)pat)[3]; } static_inline u16 byte_load_2(const void *src) { v16_uni uni; uni.v.c[0] = ((const char *)src)[0]; uni.v.c[1] = ((const char *)src)[1]; return uni.u; } static_inline u32 byte_load_3(const void *src) { v32_uni uni; uni.v.c[0] = ((const char *)src)[0]; uni.v.c[1] = ((const char *)src)[1]; uni.v.c[2] = ((const char *)src)[2]; uni.v.c[3] = 0; return uni.u; } static_inline u32 byte_load_4(const void *src) { v32_uni uni; uni.v.c[0] = ((const char *)src)[0]; uni.v.c[1] = ((const char *)src)[1]; uni.v.c[2] = ((const char *)src)[2]; uni.v.c[3] = ((const char *)src)[3]; return uni.u; } #undef byte_move_expr #else static_inline void byte_copy_2(void *dst, const void *src) { memcpy(dst, src, 2); } static_inline void byte_copy_4(void *dst, const void *src) { memcpy(dst, src, 4); } static_inline void byte_copy_8(void *dst, const void *src) { memcpy(dst, src, 8); } static_inline void byte_copy_16(void *dst, const void *src) { memcpy(dst, src, 16); } static_inline void byte_move_2(void *dst, const void *src) { u16 tmp; memcpy(&tmp, src, 2); memcpy(dst, &tmp, 2); } static_inline void byte_move_4(void *dst, const void *src) { u32 tmp; memcpy(&tmp, src, 4); memcpy(dst, &tmp, 4); } static_inline void byte_move_8(void *dst, const void *src) { u64 tmp; memcpy(&tmp, src, 8); memcpy(dst, &tmp, 8); } static_inline void byte_move_16(void *dst, const void *src) { char *pdst = (char *)dst; const char *psrc = (const char *)src; u64 tmp1, tmp2; memcpy(&tmp1, psrc, 8); memcpy(&tmp2, psrc + 8, 8); memcpy(pdst, &tmp1, 8); memcpy(pdst + 8, &tmp2, 8); } static_inline bool byte_match_2(void *buf, const char *pat) { v16_uni u1, u2; memcpy(&u1, buf, 2); memcpy(&u2, pat, 2); return u1.u == u2.u; } static_inline bool byte_match_4(void *buf, const char *pat) { v32_uni u1, u2; memcpy(&u1, buf, 4); memcpy(&u2, pat, 4); return u1.u == u2.u; } static_inline u16 byte_load_2(const void *src) { v16_uni uni; memcpy(&uni, src, 2); return uni.u; } static_inline u32 byte_load_3(const void *src) { v32_uni uni; memcpy(&uni, src, 2); uni.v.c[2] = ((const char *)src)[2]; uni.v.c[3] = 0; return uni.u; } static_inline u32 byte_load_4(const void *src) { v32_uni uni; memcpy(&uni, src, 4); return uni.u; } #endif /*============================================================================== * Number Utils * These functions are used to detect and convert NaN and Inf numbers. *============================================================================*/ /** Convert raw binary to double. */ static_inline f64 f64_from_raw(u64 u) { /* use memcpy to avoid violating the strict aliasing rule */ f64 f; memcpy(&f, &u, 8); return f; } /** Convert double to raw binary. */ static_inline u64 f64_to_raw(f64 f) { /* use memcpy to avoid violating the strict aliasing rule */ u64 u; memcpy(&u, &f, 8); return u; } /** Get raw 'infinity' with sign. */ static_inline u64 f64_raw_get_inf(bool sign) { #if YYJSON_HAS_IEEE_754 return F64_RAW_INF | ((u64)sign << 63); #elif defined(INFINITY) return f64_to_raw(sign ? -INFINITY : INFINITY); #else return f64_to_raw(sign ? -HUGE_VAL : HUGE_VAL); #endif } /** Get raw 'nan' with sign. */ static_inline u64 f64_raw_get_nan(bool sign) { #if YYJSON_HAS_IEEE_754 return F64_RAW_NAN | ((u64)sign << 63); #elif defined(NAN) return f64_to_raw(sign ? (f64)-NAN : (f64)NAN); #else return f64_to_raw((sign ? -0.0 : 0.0) / 0.0); #endif } /** Convert normalized u64 (highest bit is 1) to f64. Some compiler (such as Microsoft Visual C++ 6.0) do not support converting number from u64 to f64. This function will first convert u64 to i64 and then to f64, with `to nearest` rounding mode. */ static_inline f64 normalized_u64_to_f64(u64 val) { #if YYJSON_U64_TO_F64_NO_IMPL i64 sig = (i64)((val >> 1) | (val & 1)); return ((f64)sig) * (f64)2.0; #else return (f64)val; #endif } /*============================================================================== * Size Utils * These functions are used for memory allocation. *============================================================================*/ /** Returns whether the size is overflow after increment. */ static_inline bool size_add_is_overflow(usize size, usize add) { return size > (size + add); } /** Returns whether the size is power of 2 (size should not be 0). */ static_inline bool size_is_pow2(usize size) { return (size & (size - 1)) == 0; } /** Align size upwards (may overflow). */ static_inline usize size_align_up(usize size, usize align) { if (size_is_pow2(align)) { return (size + (align - 1)) & ~(align - 1); } else { return size + align - (size + align - 1) % align - 1; } } /** Align size downwards. */ static_inline usize size_align_down(usize size, usize align) { if (size_is_pow2(align)) { return size & ~(align - 1); } else { return size - (size % align); } } /** Align address upwards (may overflow). */ static_inline void *mem_align_up(void *mem, usize align) { usize size; memcpy(&size, &mem, sizeof(usize)); size = size_align_up(size, align); memcpy(&mem, &size, sizeof(usize)); return mem; } /*============================================================================== * Bits Utils * These functions are used by the floating-point number reader and writer. *============================================================================*/ /** Returns the number of leading 0-bits in value (input should not be 0). */ static_inline u32 u64_lz_bits(u64 v) { #if GCC_HAS_CLZLL return (u32)__builtin_clzll(v); #elif MSC_HAS_BIT_SCAN_64 unsigned long r; _BitScanReverse64(&r, v); return (u32)63 - (u32)r; #elif MSC_HAS_BIT_SCAN unsigned long hi, lo; bool hi_set = _BitScanReverse(&hi, (u32)(v >> 32)) != 0; _BitScanReverse(&lo, (u32)v); hi |= 32; return (u32)63 - (u32)(hi_set ? hi : lo); #else /* branchless, use de Bruijn sequences see: https://www.chessprogramming.org/BitScan */ const u8 table[64] = { 63, 16, 62, 7, 15, 36, 61, 3, 6, 14, 22, 26, 35, 47, 60, 2, 9, 5, 28, 11, 13, 21, 42, 19, 25, 31, 34, 40, 46, 52, 59, 1, 17, 8, 37, 4, 23, 27, 48, 10, 29, 12, 43, 20, 32, 41, 53, 18, 38, 24, 49, 30, 44, 33, 54, 39, 50, 45, 55, 51, 56, 57, 58, 0 }; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v |= v >> 32; return table[(v * U64(0x03F79D71, 0xB4CB0A89)) >> 58]; #endif } /** Returns the number of trailing 0-bits in value (input should not be 0). */ static_inline u32 u64_tz_bits(u64 v) { #if GCC_HAS_CTZLL return (u32)__builtin_ctzll(v); #elif MSC_HAS_BIT_SCAN_64 unsigned long r; _BitScanForward64(&r, v); return (u32)r; #elif MSC_HAS_BIT_SCAN unsigned long lo, hi; bool lo_set = _BitScanForward(&lo, (u32)(v)) != 0; _BitScanForward(&hi, (u32)(v >> 32)); hi += 32; return lo_set ? lo : hi; #else /* branchless, use de Bruijn sequences see: https://www.chessprogramming.org/BitScan */ const u8 table[64] = { 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 }; return table[((v & (~v + 1)) * U64(0x022FDD63, 0xCC95386D)) >> 58]; #endif } /*============================================================================== * 128-bit Integer Utils * These functions are used by the floating-point number reader and writer. *============================================================================*/ /** Multiplies two 64-bit unsigned integers (a * b), returns the 128-bit result as 'hi' and 'lo'. */ static_inline void u128_mul(u64 a, u64 b, u64 *hi, u64 *lo) { #if YYJSON_HAS_INT128 u128 m = (u128)a * b; *hi = (u64)(m >> 64); *lo = (u64)(m); #elif MSC_HAS_UMUL128 *lo = _umul128(a, b, hi); #else u32 a0 = (u32)(a), a1 = (u32)(a >> 32); u32 b0 = (u32)(b), b1 = (u32)(b >> 32); u64 p00 = (u64)a0 * b0, p01 = (u64)a0 * b1; u64 p10 = (u64)a1 * b0, p11 = (u64)a1 * b1; u64 m0 = p01 + (p00 >> 32); u32 m00 = (u32)(m0), m01 = (u32)(m0 >> 32); u64 m1 = p10 + m00; u32 m10 = (u32)(m1), m11 = (u32)(m1 >> 32); *hi = p11 + m01 + m11; *lo = ((u64)m10 << 32) | (u32)p00; #endif } /** Multiplies two 64-bit unsigned integers and add a value (a * b + c), returns the 128-bit result as 'hi' and 'lo'. */ static_inline void u128_mul_add(u64 a, u64 b, u64 c, u64 *hi, u64 *lo) { #if YYJSON_HAS_INT128 u128 m = (u128)a * b + c; *hi = (u64)(m >> 64); *lo = (u64)(m); #else u64 h, l, t; u128_mul(a, b, &h, &l); t = l + c; h += (u64)(((t < l) | (t < c))); *hi = h; *lo = t; #endif } /*============================================================================== * File Utils * These functions are used to read and write JSON files. *============================================================================*/ #define YYJSON_FOPEN_EXT #if !defined(_MSC_VER) && defined(__GLIBC__) && defined(__GLIBC_PREREQ) # if __GLIBC_PREREQ(2, 7) # undef YYJSON_FOPEN_EXT # define YYJSON_FOPEN_EXT "e" /* glibc extension to enable O_CLOEXEC */ # endif #endif static_inline FILE *fopen_safe(const char *path, const char *mode) { #if YYJSON_MSC_VER >= 1400 FILE *file = NULL; if (fopen_s(&file, path, mode) != 0) return NULL; return file; #else return fopen(path, mode); #endif } static_inline FILE *fopen_readonly(const char *path) { return fopen_safe(path, "rb" YYJSON_FOPEN_EXT); } static_inline FILE *fopen_writeonly(const char *path) { return fopen_safe(path, "wb" YYJSON_FOPEN_EXT); } static_inline usize fread_safe(void *buf, usize size, FILE *file) { #if YYJSON_MSC_VER >= 1400 return fread_s(buf, size, 1, size, file); #else return fread(buf, 1, size, file); #endif } /*============================================================================== * Default Memory Allocator * This is a simple libc memory allocator wrapper. *============================================================================*/ static void *default_malloc(void *ctx, usize size) { return malloc(size); } static void *default_realloc(void *ctx, void *ptr, usize old_size, usize size) { return realloc(ptr, size); } static void default_free(void *ctx, void *ptr) { free(ptr); } static const yyjson_alc YYJSON_DEFAULT_ALC = { default_malloc, default_realloc, default_free, NULL }; /*============================================================================== * Null Memory Allocator * * This allocator is just a placeholder to ensure that the internal * malloc/realloc/free function pointers are not null. *============================================================================*/ static void *null_malloc(void *ctx, usize size) { return NULL; } static void *null_realloc(void *ctx, void *ptr, usize old_size, usize size) { return NULL; } static void null_free(void *ctx, void *ptr) { return; } static const yyjson_alc YYJSON_NULL_ALC = { null_malloc, null_realloc, null_free, NULL }; /*============================================================================== * Pool Memory Allocator * * This allocator is initialized with a fixed-size buffer. * The buffer is split into multiple memory chunks for memory allocation. *============================================================================*/ /** memory chunk header */ typedef struct pool_chunk { usize size; /* chunk memory size, include chunk header */ struct pool_chunk *next; /* linked list, nullable */ /* char mem[]; flexible array member */ } pool_chunk; /** allocator ctx header */ typedef struct pool_ctx { usize size; /* total memory size, include ctx header */ pool_chunk *free_list; /* linked list, nullable */ /* pool_chunk chunks[]; flexible array member */ } pool_ctx; /** align up the input size to chunk size */ static_inline void pool_size_align(usize *size) { *size = size_align_up(*size, sizeof(pool_chunk)) + sizeof(pool_chunk); } static void *pool_malloc(void *ctx_ptr, usize size) { /* assert(size != 0) */ pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *next, *prev = NULL, *cur = ctx->free_list; if (unlikely(size >= ctx->size)) return NULL; pool_size_align(&size); while (cur) { if (cur->size < size) { /* not enough space, try next chunk */ prev = cur; cur = cur->next; continue; } if (cur->size >= size + sizeof(pool_chunk) * 2) { /* too much space, split this chunk */ next = (pool_chunk *)(void *)((u8 *)cur + size); next->size = cur->size - size; next->next = cur->next; cur->size = size; } else { /* just enough space, use whole chunk */ next = cur->next; } if (prev) prev->next = next; else ctx->free_list = next; return (void *)(cur + 1); } return NULL; } static void pool_free(void *ctx_ptr, void *ptr) { /* assert(ptr != NULL) */ pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *cur = ((pool_chunk *)ptr) - 1; pool_chunk *prev = NULL, *next = ctx->free_list; while (next && next < cur) { prev = next; next = next->next; } if (prev) prev->next = cur; else ctx->free_list = cur; cur->next = next; if (next && ((u8 *)cur + cur->size) == (u8 *)next) { /* merge cur to higher chunk */ cur->size += next->size; cur->next = next->next; } if (prev && ((u8 *)prev + prev->size) == (u8 *)cur) { /* merge cur to lower chunk */ prev->size += cur->size; prev->next = cur->next; } } static void *pool_realloc(void *ctx_ptr, void *ptr, usize old_size, usize size) { /* assert(ptr != NULL && size != 0 && old_size < size) */ pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *cur = ((pool_chunk *)ptr) - 1, *prev, *next, *tmp; /* check size */ if (unlikely(size >= ctx->size)) return NULL; pool_size_align(&old_size); pool_size_align(&size); if (unlikely(old_size == size)) return ptr; /* find next and prev chunk */ prev = NULL; next = ctx->free_list; while (next && next < cur) { prev = next; next = next->next; } if ((u8 *)cur + cur->size == (u8 *)next && cur->size + next->size >= size) { /* merge to higher chunk if they are contiguous */ usize free_size = cur->size + next->size - size; if (free_size > sizeof(pool_chunk) * 2) { tmp = (pool_chunk *)(void *)((u8 *)cur + size); if (prev) prev->next = tmp; else ctx->free_list = tmp; tmp->next = next->next; tmp->size = free_size; cur->size = size; } else { if (prev) prev->next = next->next; else ctx->free_list = next->next; cur->size += next->size; } return ptr; } else { /* fallback to malloc and memcpy */ void *new_ptr = pool_malloc(ctx_ptr, size - sizeof(pool_chunk)); if (new_ptr) { memcpy(new_ptr, ptr, cur->size - sizeof(pool_chunk)); pool_free(ctx_ptr, ptr); } return new_ptr; } } bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size) { pool_chunk *chunk; pool_ctx *ctx; if (unlikely(!alc)) return false; *alc = YYJSON_NULL_ALC; if (size < sizeof(pool_ctx) * 4) return false; ctx = (pool_ctx *)mem_align_up(buf, sizeof(pool_ctx)); if (unlikely(!ctx)) return false; size -= (usize)((u8 *)ctx - (u8 *)buf); size = size_align_down(size, sizeof(pool_ctx)); chunk = (pool_chunk *)(ctx + 1); chunk->size = size - sizeof(pool_ctx); chunk->next = NULL; ctx->size = size; ctx->free_list = chunk; alc->malloc = pool_malloc; alc->realloc = pool_realloc; alc->free = pool_free; alc->ctx = (void *)ctx; return true; } /*============================================================================== * Dynamic Memory Allocator * * This allocator allocates memory on demand and does not immediately release * unused memory. Instead, it places the unused memory into a freelist for * potential reuse in the future. It is only when the entire allocator is * destroyed that all previously allocated memory is released at once. *============================================================================*/ /** memory chunk header */ typedef struct dyn_chunk { usize size; /* chunk size, include header */ struct dyn_chunk *next; /* char mem[]; flexible array member */ } dyn_chunk; /** allocator ctx header */ typedef struct { dyn_chunk free_list; /* dummy header, sorted from small to large */ dyn_chunk used_list; /* dummy header */ } dyn_ctx; /** align up the input size to chunk size */ static_inline bool dyn_size_align(usize *size) { usize alc_size = *size + sizeof(dyn_chunk); alc_size = size_align_up(alc_size, YYJSON_ALC_DYN_MIN_SIZE); if (unlikely(alc_size < *size)) return false; /* overflow */ *size = alc_size; return true; } /** remove a chunk from list (the chunk must already be in the list) */ static_inline void dyn_chunk_list_remove(dyn_chunk *list, dyn_chunk *chunk) { dyn_chunk *prev = list, *cur; for (cur = prev->next; cur; cur = cur->next) { if (cur == chunk) { prev->next = cur->next; cur->next = NULL; return; } prev = cur; } } /** add a chunk to list header (the chunk must not be in the list) */ static_inline void dyn_chunk_list_add(dyn_chunk *list, dyn_chunk *chunk) { chunk->next = list->next; list->next = chunk; } static void *dyn_malloc(void *ctx_ptr, usize size) { /* assert(size != 0) */ const yyjson_alc def = YYJSON_DEFAULT_ALC; dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; dyn_chunk *chunk, *prev, *next; if (unlikely(!dyn_size_align(&size))) return NULL; /* freelist is empty, create new chunk */ if (!ctx->free_list.next) { chunk = (dyn_chunk *)def.malloc(def.ctx, size); if (unlikely(!chunk)) return NULL; chunk->size = size; chunk->next = NULL; dyn_chunk_list_add(&ctx->used_list, chunk); return (void *)(chunk + 1); } /* find a large enough chunk, or resize the largest chunk */ prev = &ctx->free_list; while (true) { chunk = prev->next; if (chunk->size >= size) { /* enough size, reuse this chunk */ prev->next = chunk->next; dyn_chunk_list_add(&ctx->used_list, chunk); return (void *)(chunk + 1); } if (!chunk->next) { /* resize the largest chunk */ chunk = (dyn_chunk *)def.realloc(def.ctx, chunk, chunk->size, size); if (unlikely(!chunk)) return NULL; prev->next = NULL; chunk->size = size; dyn_chunk_list_add(&ctx->used_list, chunk); return (void *)(chunk + 1); } prev = chunk; } } static void *dyn_realloc(void *ctx_ptr, void *ptr, usize old_size, usize size) { /* assert(ptr != NULL && size != 0 && old_size < size) */ const yyjson_alc def = YYJSON_DEFAULT_ALC; dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; dyn_chunk *prev, *next, *new_chunk; dyn_chunk *chunk = (dyn_chunk *)ptr - 1; if (unlikely(!dyn_size_align(&size))) return NULL; if (chunk->size >= size) return ptr; dyn_chunk_list_remove(&ctx->used_list, chunk); new_chunk = (dyn_chunk *)def.realloc(def.ctx, chunk, chunk->size, size); if (likely(new_chunk)) { new_chunk->size = size; chunk = new_chunk; } dyn_chunk_list_add(&ctx->used_list, chunk); return new_chunk ? (void *)(new_chunk + 1) : NULL; } static void dyn_free(void *ctx_ptr, void *ptr) { /* assert(ptr != NULL) */ dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; dyn_chunk *chunk = (dyn_chunk *)ptr - 1, *prev; dyn_chunk_list_remove(&ctx->used_list, chunk); for (prev = &ctx->free_list; prev; prev = prev->next) { if (!prev->next || prev->next->size >= chunk->size) { chunk->next = prev->next; prev->next = chunk; break; } } } yyjson_alc *yyjson_alc_dyn_new(void) { const yyjson_alc def = YYJSON_DEFAULT_ALC; usize hdr_len = sizeof(yyjson_alc) + sizeof(dyn_ctx); yyjson_alc *alc = (yyjson_alc *)def.malloc(def.ctx, hdr_len); dyn_ctx *ctx = (dyn_ctx *)(void *)(alc + 1); if (unlikely(!alc)) return NULL; alc->malloc = dyn_malloc; alc->realloc = dyn_realloc; alc->free = dyn_free; alc->ctx = alc + 1; memset(ctx, 0, sizeof(*ctx)); return alc; } void yyjson_alc_dyn_free(yyjson_alc *alc) { const yyjson_alc def = YYJSON_DEFAULT_ALC; dyn_ctx *ctx = (dyn_ctx *)(void *)(alc + 1); dyn_chunk *chunk, *next; if (unlikely(!alc)) return; for (chunk = ctx->free_list.next; chunk; chunk = next) { next = chunk->next; def.free(def.ctx, chunk); } for (chunk = ctx->used_list.next; chunk; chunk = next) { next = chunk->next; def.free(def.ctx, chunk); } def.free(def.ctx, alc); } /*============================================================================== * JSON document and value *============================================================================*/ static_inline void unsafe_yyjson_str_pool_release(yyjson_str_pool *pool, yyjson_alc *alc) { yyjson_str_chunk *chunk = pool->chunks, *next; while (chunk) { next = chunk->next; alc->free(alc->ctx, chunk); chunk = next; } } static_inline void unsafe_yyjson_val_pool_release(yyjson_val_pool *pool, yyjson_alc *alc) { yyjson_val_chunk *chunk = pool->chunks, *next; while (chunk) { next = chunk->next; alc->free(alc->ctx, chunk); chunk = next; } } bool unsafe_yyjson_str_pool_grow(yyjson_str_pool *pool, const yyjson_alc *alc, usize len) { yyjson_str_chunk *chunk; usize size, max_len; /* create a new chunk */ max_len = USIZE_MAX - sizeof(yyjson_str_chunk); if (unlikely(len > max_len)) return false; size = len + sizeof(yyjson_str_chunk); size = yyjson_max(pool->chunk_size, size); chunk = (yyjson_str_chunk *)alc->malloc(alc->ctx, size); if (unlikely(!chunk)) return false; /* insert the new chunk as the head of the linked list */ chunk->next = pool->chunks; chunk->chunk_size = size; pool->chunks = chunk; pool->cur = (char *)chunk + sizeof(yyjson_str_chunk); pool->end = (char *)chunk + size; /* the next chunk is twice the size of the current one */ size = yyjson_min(pool->chunk_size * 2, pool->chunk_size_max); if (size < pool->chunk_size) size = pool->chunk_size_max; /* overflow */ pool->chunk_size = size; return true; } bool unsafe_yyjson_val_pool_grow(yyjson_val_pool *pool, const yyjson_alc *alc, usize count) { yyjson_val_chunk *chunk; usize size, max_count; /* create a new chunk */ max_count = USIZE_MAX / sizeof(yyjson_mut_val) - 1; if (unlikely(count > max_count)) return false; size = (count + 1) * sizeof(yyjson_mut_val); size = yyjson_max(pool->chunk_size, size); chunk = (yyjson_val_chunk *)alc->malloc(alc->ctx, size); if (unlikely(!chunk)) return false; /* insert the new chunk as the head of the linked list */ chunk->next = pool->chunks; chunk->chunk_size = size; pool->chunks = chunk; pool->cur = (yyjson_mut_val *)(void *)((u8 *)chunk) + 1; pool->end = (yyjson_mut_val *)(void *)((u8 *)chunk + size); /* the next chunk is twice the size of the current one */ size = yyjson_min(pool->chunk_size * 2, pool->chunk_size_max); if (size < pool->chunk_size) size = pool->chunk_size_max; /* overflow */ pool->chunk_size = size; return true; } bool yyjson_mut_doc_set_str_pool_size(yyjson_mut_doc *doc, size_t len) { usize max_size = USIZE_MAX - sizeof(yyjson_str_chunk); if (!doc || !len || len > max_size) return false; doc->str_pool.chunk_size = len + sizeof(yyjson_str_chunk); return true; } bool yyjson_mut_doc_set_val_pool_size(yyjson_mut_doc *doc, size_t count) { usize max_count = USIZE_MAX / sizeof(yyjson_mut_val) - 1; if (!doc || !count || count > max_count) return false; doc->val_pool.chunk_size = (count + 1) * sizeof(yyjson_mut_val); return true; } void yyjson_mut_doc_free(yyjson_mut_doc *doc) { if (doc) { yyjson_alc alc = doc->alc; memset(&doc->alc, 0, sizeof(alc)); unsafe_yyjson_str_pool_release(&doc->str_pool, &alc); unsafe_yyjson_val_pool_release(&doc->val_pool, &alc); alc.free(alc.ctx, doc); } } yyjson_mut_doc *yyjson_mut_doc_new(const yyjson_alc *alc) { yyjson_mut_doc *doc; if (!alc) alc = &YYJSON_DEFAULT_ALC; doc = (yyjson_mut_doc *)alc->malloc(alc->ctx, sizeof(yyjson_mut_doc)); if (!doc) return NULL; memset(doc, 0, sizeof(yyjson_mut_doc)); doc->alc = *alc; doc->str_pool.chunk_size = YYJSON_MUT_DOC_STR_POOL_INIT_SIZE; doc->str_pool.chunk_size_max = YYJSON_MUT_DOC_STR_POOL_MAX_SIZE; doc->val_pool.chunk_size = YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE; doc->val_pool.chunk_size_max = YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE; return doc; } yyjson_mut_doc *yyjson_doc_mut_copy(yyjson_doc *doc, const yyjson_alc *alc) { yyjson_mut_doc *m_doc; yyjson_mut_val *m_val; if (!doc || !doc->root) return NULL; m_doc = yyjson_mut_doc_new(alc); if (!m_doc) return NULL; m_val = yyjson_val_mut_copy(m_doc, doc->root); if (!m_val) { yyjson_mut_doc_free(m_doc); return NULL; } yyjson_mut_doc_set_root(m_doc, m_val); return m_doc; } yyjson_mut_doc *yyjson_mut_doc_mut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc) { yyjson_mut_doc *m_doc; yyjson_mut_val *m_val; if (!doc) return NULL; if (!doc->root) return yyjson_mut_doc_new(alc); m_doc = yyjson_mut_doc_new(alc); if (!m_doc) return NULL; m_val = yyjson_mut_val_mut_copy(m_doc, doc->root); if (!m_val) { yyjson_mut_doc_free(m_doc); return NULL; } yyjson_mut_doc_set_root(m_doc, m_val); return m_doc; } yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *m_doc, yyjson_val *i_vals) { /* The immutable object or array stores all sub-values in a contiguous memory, We copy them to another contiguous memory as mutable values, then reconnect the mutable values with the original relationship. */ usize i_vals_len; yyjson_mut_val *m_vals, *m_val; yyjson_val *i_val, *i_end; if (!m_doc || !i_vals) return NULL; i_end = unsafe_yyjson_get_next(i_vals); i_vals_len = (usize)(unsafe_yyjson_get_next(i_vals) - i_vals); m_vals = unsafe_yyjson_mut_val(m_doc, i_vals_len); if (!m_vals) return NULL; i_val = i_vals; m_val = m_vals; for (; i_val < i_end; i_val++, m_val++) { yyjson_type type = unsafe_yyjson_get_type(i_val); m_val->tag = i_val->tag; m_val->uni.u64 = i_val->uni.u64; if (type == YYJSON_TYPE_STR || type == YYJSON_TYPE_RAW) { const char *str = i_val->uni.str; usize str_len = unsafe_yyjson_get_len(i_val); m_val->uni.str = unsafe_yyjson_mut_strncpy(m_doc, str, str_len); if (!m_val->uni.str) return NULL; } else if (type == YYJSON_TYPE_ARR) { usize len = unsafe_yyjson_get_len(i_val); if (len > 0) { yyjson_val *ii_val = i_val + 1, *ii_next; yyjson_mut_val *mm_val = m_val + 1, *mm_ctn = m_val, *mm_next; while (len-- > 1) { ii_next = unsafe_yyjson_get_next(ii_val); mm_next = mm_val + (ii_next - ii_val); mm_val->next = mm_next; ii_val = ii_next; mm_val = mm_next; } mm_val->next = mm_ctn + 1; mm_ctn->uni.ptr = mm_val; } } else if (type == YYJSON_TYPE_OBJ) { usize len = unsafe_yyjson_get_len(i_val); if (len > 0) { yyjson_val *ii_key = i_val + 1, *ii_nextkey; yyjson_mut_val *mm_key = m_val + 1, *mm_ctn = m_val; yyjson_mut_val *mm_nextkey; while (len-- > 1) { ii_nextkey = unsafe_yyjson_get_next(ii_key + 1); mm_nextkey = mm_key + (ii_nextkey - ii_key); mm_key->next = mm_key + 1; mm_key->next->next = mm_nextkey; ii_key = ii_nextkey; mm_key = mm_nextkey; } mm_key->next = mm_key + 1; mm_key->next->next = mm_ctn + 1; mm_ctn->uni.ptr = mm_key; } } } return m_vals; } static yyjson_mut_val *unsafe_yyjson_mut_val_mut_copy(yyjson_mut_doc *m_doc, yyjson_mut_val *m_vals) { /* The mutable object or array stores all sub-values in a circular linked list, so we can traverse them in the same loop. The traversal starts from the last item, continues with the first item in a list, and ends with the second to last item, which needs to be linked to the last item to close the circle. */ yyjson_mut_val *m_val = unsafe_yyjson_mut_val(m_doc, 1); if (unlikely(!m_val)) return NULL; m_val->tag = m_vals->tag; switch (unsafe_yyjson_get_type(m_vals)) { case YYJSON_TYPE_OBJ: case YYJSON_TYPE_ARR: if (unsafe_yyjson_get_len(m_vals) > 0) { yyjson_mut_val *last = (yyjson_mut_val *)m_vals->uni.ptr; yyjson_mut_val *next = last->next, *prev; prev = unsafe_yyjson_mut_val_mut_copy(m_doc, last); if (!prev) return NULL; m_val->uni.ptr = (void *)prev; while (next != last) { prev->next = unsafe_yyjson_mut_val_mut_copy(m_doc, next); if (!prev->next) return NULL; prev = prev->next; next = next->next; } prev->next = (yyjson_mut_val *)m_val->uni.ptr; } break; case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: { const char *str = m_vals->uni.str; usize str_len = unsafe_yyjson_get_len(m_vals); m_val->uni.str = unsafe_yyjson_mut_strncpy(m_doc, str, str_len); if (!m_val->uni.str) return NULL; break; } default: m_val->uni = m_vals->uni; break; } return m_val; } yyjson_mut_val *yyjson_mut_val_mut_copy(yyjson_mut_doc *doc, yyjson_mut_val *val) { if (doc && val) return unsafe_yyjson_mut_val_mut_copy(doc, val); return NULL; } /* Count the number of values and the total length of the strings. */ static void yyjson_mut_stat(yyjson_mut_val *val, usize *val_sum, usize *str_sum) { yyjson_type type = unsafe_yyjson_get_type(val); *val_sum += 1; if (type == YYJSON_TYPE_ARR || type == YYJSON_TYPE_OBJ) { yyjson_mut_val *child = (yyjson_mut_val *)val->uni.ptr; usize len = unsafe_yyjson_get_len(val), i; len <<= (u8)(type == YYJSON_TYPE_OBJ); *val_sum += len; for (i = 0; i < len; i++) { yyjson_type stype = unsafe_yyjson_get_type(child); if (stype == YYJSON_TYPE_STR || stype == YYJSON_TYPE_RAW) { *str_sum += unsafe_yyjson_get_len(child) + 1; } else if (stype == YYJSON_TYPE_ARR || stype == YYJSON_TYPE_OBJ) { yyjson_mut_stat(child, val_sum, str_sum); *val_sum -= 1; } child = child->next; } } else if (type == YYJSON_TYPE_STR || type == YYJSON_TYPE_RAW) { *str_sum += unsafe_yyjson_get_len(val) + 1; } } /* Copy mutable values to immutable value pool. */ static usize yyjson_imut_copy(yyjson_val **val_ptr, char **buf_ptr, yyjson_mut_val *mval) { yyjson_val *val = *val_ptr; yyjson_type type = unsafe_yyjson_get_type(mval); if (type == YYJSON_TYPE_ARR || type == YYJSON_TYPE_OBJ) { yyjson_mut_val *child = (yyjson_mut_val *)mval->uni.ptr; usize len = unsafe_yyjson_get_len(mval), i; usize val_sum = 1; if (type == YYJSON_TYPE_OBJ) { if (len) child = child->next->next; len <<= 1; } else { if (len) child = child->next; } *val_ptr = val + 1; for (i = 0; i < len; i++) { val_sum += yyjson_imut_copy(val_ptr, buf_ptr, child); child = child->next; } val->tag = mval->tag; val->uni.ofs = val_sum * sizeof(yyjson_val); return val_sum; } else if (type == YYJSON_TYPE_STR || type == YYJSON_TYPE_RAW) { char *buf = *buf_ptr; usize len = unsafe_yyjson_get_len(mval); memcpy((void *)buf, (const void *)mval->uni.str, len); buf[len] = '\0'; val->tag = mval->tag; val->uni.str = buf; *val_ptr = val + 1; *buf_ptr = buf + len + 1; return 1; } else { val->tag = mval->tag; val->uni = mval->uni; *val_ptr = val + 1; return 1; } } yyjson_doc *yyjson_mut_doc_imut_copy(yyjson_mut_doc *mdoc, const yyjson_alc *alc) { if (!mdoc) return NULL; return yyjson_mut_val_imut_copy(mdoc->root, alc); } yyjson_doc *yyjson_mut_val_imut_copy(yyjson_mut_val *mval, const yyjson_alc *alc) { usize val_num = 0, str_sum = 0, hdr_size, buf_size; yyjson_doc *doc = NULL; yyjson_val *val_hdr = NULL; /* This value should be NULL here. Setting a non-null value suppresses warning from the clang analyzer. */ char *str_hdr = (char *)(void *)&str_sum; if (!mval) return NULL; if (!alc) alc = &YYJSON_DEFAULT_ALC; /* traverse the input value to get pool size */ yyjson_mut_stat(mval, &val_num, &str_sum); /* create doc and val pool */ hdr_size = size_align_up(sizeof(yyjson_doc), sizeof(yyjson_val)); buf_size = hdr_size + val_num * sizeof(yyjson_val); doc = (yyjson_doc *)alc->malloc(alc->ctx, buf_size); if (!doc) return NULL; memset(doc, 0, sizeof(yyjson_doc)); val_hdr = (yyjson_val *)(void *)((char *)(void *)doc + hdr_size); doc->root = val_hdr; doc->alc = *alc; /* create str pool */ if (str_sum > 0) { str_hdr = (char *)alc->malloc(alc->ctx, str_sum); doc->str_pool = str_hdr; if (!str_hdr) { alc->free(alc->ctx, (void *)doc); return NULL; } } /* copy vals and strs */ doc->val_read = yyjson_imut_copy(&val_hdr, &str_hdr, mval); doc->dat_read = str_sum + 1; return doc; } static_inline bool unsafe_yyjson_num_equals(void *lhs, void *rhs) { yyjson_val_uni *luni = &((yyjson_val *)lhs)->uni; yyjson_val_uni *runi = &((yyjson_val *)rhs)->uni; yyjson_subtype lt = unsafe_yyjson_get_subtype(lhs); yyjson_subtype rt = unsafe_yyjson_get_subtype(rhs); if (lt == rt) return luni->u64 == runi->u64; if (lt == YYJSON_SUBTYPE_SINT && rt == YYJSON_SUBTYPE_UINT) { return luni->i64 >= 0 && luni->u64 == runi->u64; } if (lt == YYJSON_SUBTYPE_UINT && rt == YYJSON_SUBTYPE_SINT) { return runi->i64 >= 0 && luni->u64 == runi->u64; } return false; } static_inline bool unsafe_yyjson_str_equals(void *lhs, void *rhs) { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; return !memcmp(unsafe_yyjson_get_str(lhs), unsafe_yyjson_get_str(rhs), len); } bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { yyjson_type type = unsafe_yyjson_get_type(lhs); if (type != unsafe_yyjson_get_type(rhs)) return false; switch (type) { case YYJSON_TYPE_OBJ: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; if (len > 0) { yyjson_obj_iter iter; yyjson_obj_iter_init(rhs, &iter); lhs = unsafe_yyjson_get_first(lhs); while (len-- > 0) { rhs = yyjson_obj_iter_getn(&iter, lhs->uni.str, unsafe_yyjson_get_len(lhs)); if (!rhs) return false; if (!unsafe_yyjson_equals(lhs + 1, rhs)) return false; lhs = unsafe_yyjson_get_next(lhs + 1); } } /* yyjson allows duplicate keys, so the check may be inaccurate */ return true; } case YYJSON_TYPE_ARR: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; if (len > 0) { lhs = unsafe_yyjson_get_first(lhs); rhs = unsafe_yyjson_get_first(rhs); while (len-- > 0) { if (!unsafe_yyjson_equals(lhs, rhs)) return false; lhs = unsafe_yyjson_get_next(lhs); rhs = unsafe_yyjson_get_next(rhs); } } return true; } case YYJSON_TYPE_NUM: return unsafe_yyjson_num_equals(lhs, rhs); case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: return unsafe_yyjson_str_equals(lhs, rhs); case YYJSON_TYPE_NULL: case YYJSON_TYPE_BOOL: return lhs->tag == rhs->tag; default: return false; } } bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) { yyjson_type type = unsafe_yyjson_get_type(lhs); if (type != unsafe_yyjson_get_type(rhs)) return false; switch (type) { case YYJSON_TYPE_OBJ: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; if (len > 0) { yyjson_mut_obj_iter iter; yyjson_mut_obj_iter_init(rhs, &iter); lhs = (yyjson_mut_val *)lhs->uni.ptr; while (len-- > 0) { rhs = yyjson_mut_obj_iter_getn(&iter, lhs->uni.str, unsafe_yyjson_get_len(lhs)); if (!rhs) return false; if (!unsafe_yyjson_mut_equals(lhs->next, rhs)) return false; lhs = lhs->next->next; } } /* yyjson allows duplicate keys, so the check may be inaccurate */ return true; } case YYJSON_TYPE_ARR: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; if (len > 0) { lhs = (yyjson_mut_val *)lhs->uni.ptr; rhs = (yyjson_mut_val *)rhs->uni.ptr; while (len-- > 0) { if (!unsafe_yyjson_mut_equals(lhs, rhs)) return false; lhs = lhs->next; rhs = rhs->next; } } return true; } case YYJSON_TYPE_NUM: return unsafe_yyjson_num_equals(lhs, rhs); case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: return unsafe_yyjson_str_equals(lhs, rhs); case YYJSON_TYPE_NULL: case YYJSON_TYPE_BOOL: return lhs->tag == rhs->tag; default: return false; } } #if !YYJSON_DISABLE_UTILS /*============================================================================== * JSON Pointer API (RFC 6901) *============================================================================*/ /** Get a token from JSON pointer string. @param ptr [in,out] in: string that points to current token prefix `/` out: string that points to next token prefix `/`, or string end @param end [in] end of the entire JSON Pointer string @param len [out] unescaped token length @param esc [out] number of escaped characters in this token @return head of the token, or NULL if syntax error */ static_inline const char *ptr_next_token(const char **ptr, const char *end, usize *len, usize *esc) { const char *hdr = *ptr + 1; const char *cur = hdr; /* skip unescaped characters */ while (cur < end && *cur != '/' && *cur != '~') cur++; if (likely(cur == end || *cur != '~')) { /* no escaped characters, return */ *ptr = cur; *len = (usize)(cur - hdr); *esc = 0; return hdr; } else { /* handle escaped characters */ usize esc_num = 0; while (cur < end && *cur != '/') { if (*cur++ == '~') { if (cur == end || (*cur != '0' && *cur != '1')) { *ptr = cur - 1; return NULL; } esc_num++; } } *ptr = cur; *len = (usize)(cur - hdr) - esc_num; *esc = esc_num; return hdr; } } /** Convert token string to index. @param cur [in] token head @param len [in] token length @param idx [out] the index number, or USIZE_MAX if token is '-' @return true if token is a valid array index */ static_inline bool ptr_token_to_idx(const char *cur, usize len, usize *idx) { const char *end = cur + len; usize num = 0, add; if (unlikely(len == 0 || len > USIZE_SAFE_DIG)) return false; if (*cur == '0') { if (unlikely(len > 1)) return false; *idx = 0; return true; } if (*cur == '-') { if (unlikely(len > 1)) return false; *idx = USIZE_MAX; return true; } for (; cur < end && (add = (usize)((u8)*cur - (u8)'0')) <= 9; cur++) { num = num * 10 + add; } if (unlikely(num == 0 || cur < end)) return false; *idx = num; return true; } /** Compare JSON key with token. @param key a string key (yyjson_val or yyjson_mut_val) @param token a JSON pointer token @param len unescaped token length @param esc number of escaped characters in this token @return true if `str` is equals to `token` */ static_inline bool ptr_token_eq(void *key, const char *token, usize len, usize esc) { yyjson_val *val = (yyjson_val *)key; if (unsafe_yyjson_get_len(val) != len) return false; if (likely(!esc)) { return memcmp(val->uni.str, token, len) == 0; } else { const char *str = val->uni.str; for (; len-- > 0; token++, str++) { if (*token == '~') { if (*str != (*++token == '0' ? '~' : '/')) return false; } else { if (*str != *token) return false; } } return true; } } /** Get a value from array by token. @param arr an array, should not be NULL or non-array type @param token a JSON pointer token @param len unescaped token length @param esc number of escaped characters in this token @return value at index, or NULL if token is not index or index is out of range */ static_inline yyjson_val *ptr_arr_get(yyjson_val *arr, const char *token, usize len, usize esc) { yyjson_val *val = unsafe_yyjson_get_first(arr); usize num = unsafe_yyjson_get_len(arr), idx = 0; if (unlikely(num == 0)) return NULL; if (unlikely(!ptr_token_to_idx(token, len, &idx))) return NULL; if (unlikely(idx >= num)) return NULL; if (unsafe_yyjson_arr_is_flat(arr)) { return val + idx; } else { while (idx-- > 0) val = unsafe_yyjson_get_next(val); return val; } } /** Get a value from object by token. @param obj [in] an object, should not be NULL or non-object type @param token [in] a JSON pointer token @param len [in] unescaped token length @param esc [in] number of escaped characters in this token @return value associated with the token, or NULL if no value */ static_inline yyjson_val *ptr_obj_get(yyjson_val *obj, const char *token, usize len, usize esc) { yyjson_val *key = unsafe_yyjson_get_first(obj); usize num = unsafe_yyjson_get_len(obj); if (unlikely(num == 0)) return NULL; for (; num > 0; num--, key = unsafe_yyjson_get_next(key + 1)) { if (ptr_token_eq(key, token, len, esc)) return key + 1; } return NULL; } /** Get a value from array by token. @param arr [in] an array, should not be NULL or non-array type @param token [in] a JSON pointer token @param len [in] unescaped token length @param esc [in] number of escaped characters in this token @param pre [out] previous (sibling) value of the returned value @param last [out] whether index is last @return value at index, or NULL if token is not index or index is out of range */ static_inline yyjson_mut_val *ptr_mut_arr_get(yyjson_mut_val *arr, const char *token, usize len, usize esc, yyjson_mut_val **pre, bool *last) { yyjson_mut_val *val = (yyjson_mut_val *)arr->uni.ptr; /* last (tail) */ usize num = unsafe_yyjson_get_len(arr), idx; if (last) *last = false; if (false) *pre = NULL; if (unlikely(num == 0)) { if (last && len == 1 && (*token == '0' || *token == '-')) *last = true; return NULL; } if (unlikely(!ptr_token_to_idx(token, len, &idx))) return NULL; if (last) *last = (idx == num || idx == USIZE_MAX); if (unlikely(idx >= num)) return NULL; while (idx-- > 0) val = val->next; *pre = val; return val->next; } /** Get a value from object by token. @param obj [in] an object, should not be NULL or non-object type @param token [in] a JSON pointer token @param len [in] unescaped token length @param esc [in] number of escaped characters in this token @param pre [out] previous (sibling) key of the returned value's key @return value associated with the token, or NULL if no value */ static_inline yyjson_mut_val *ptr_mut_obj_get(yyjson_mut_val *obj, const char *token, usize len, usize esc, yyjson_mut_val **pre) { yyjson_mut_val *pre_key = (yyjson_mut_val *)obj->uni.ptr, *key; usize num = unsafe_yyjson_get_len(obj); if (false) *pre = NULL; if (unlikely(num == 0)) return NULL; for (; num > 0; num--, pre_key = key) { key = pre_key->next->next; if (ptr_token_eq(key, token, len, esc)) { *pre = pre_key; return key->next; } } return NULL; } /** Create a string value with JSON pointer token. @param token [in] a JSON pointer token @param len [in] unescaped token length @param esc [in] number of escaped characters in this token @param doc [in] used for memory allocation when creating value @return new string value, or NULL if memory allocation failed */ static_inline yyjson_mut_val *ptr_new_key(const char *token, usize len, usize esc, yyjson_mut_doc *doc) { const char *src = token; if (likely(!esc)) { return yyjson_mut_strncpy(doc, src, len); } else { const char *end = src + len + esc; char *dst = unsafe_yyjson_mut_str_alc(doc, len + esc); char *str = dst; if (unlikely(!dst)) return NULL; for (; src < end; src++, dst++) { if (*src != '~') *dst = *src; else *dst = (*++src == '0' ? '~' : '/'); } *dst = '\0'; return yyjson_mut_strn(doc, str, len); } } /* macros for yyjson_ptr */ #define return_err(_ret, _code, _pos, _msg) do { \ if (err) { \ err->code = YYJSON_PTR_ERR_##_code; \ err->msg = _msg; \ err->pos = (usize)(_pos); \ } \ return _ret; \ } while (false) #define return_err_resolve(_ret, _pos) \ return_err(_ret, RESOLVE, _pos, "JSON pointer cannot be resolved") #define return_err_syntax(_ret, _pos) \ return_err(_ret, SYNTAX, _pos, "invalid escaped character") #define return_err_alloc(_ret) \ return_err(_ret, MEMORY_ALLOCATION, 0, "failed to create value") yyjson_val *unsafe_yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t ptr_len, yyjson_ptr_err *err) { const char *hdr = ptr, *end = ptr + ptr_len, *token; usize len, esc; yyjson_type type; while (true) { token = ptr_next_token(&ptr, end, &len, &esc); if (unlikely(!token)) return_err_syntax(NULL, ptr - hdr); type = unsafe_yyjson_get_type(val); if (type == YYJSON_TYPE_OBJ) { val = ptr_obj_get(val, token, len, esc); } else if (type == YYJSON_TYPE_ARR) { val = ptr_arr_get(val, token, len, esc); } else { val = NULL; } if (!val) return_err_resolve(NULL, token - hdr); if (ptr == end) return val; } } yyjson_mut_val *unsafe_yyjson_mut_ptr_getx(yyjson_mut_val *val, const char *ptr, size_t ptr_len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { const char *hdr = ptr, *end = ptr + ptr_len, *token; usize len, esc; yyjson_mut_val *ctn, *pre = NULL; yyjson_type type; bool idx_is_last = false; while (true) { token = ptr_next_token(&ptr, end, &len, &esc); if (unlikely(!token)) return_err_syntax(NULL, ptr - hdr); ctn = val; type = unsafe_yyjson_get_type(val); if (type == YYJSON_TYPE_OBJ) { val = ptr_mut_obj_get(val, token, len, esc, &pre); } else if (type == YYJSON_TYPE_ARR) { val = ptr_mut_arr_get(val, token, len, esc, &pre, &idx_is_last); } else { val = NULL; } if (ctx && (ptr == end)) { if (type == YYJSON_TYPE_OBJ || (type == YYJSON_TYPE_ARR && (val || idx_is_last))) { ctx->ctn = ctn; ctx->pre = pre; } } if (!val) return_err_resolve(NULL, token - hdr); if (ptr == end) return val; } } bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, const char *ptr, size_t ptr_len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, bool insert_new, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { const char *hdr = ptr, *end = ptr + ptr_len, *token; usize token_len, esc, ctn_len; yyjson_mut_val *ctn, *key, *pre = NULL; yyjson_mut_val *sep_ctn = NULL, *sep_key = NULL, *sep_val = NULL; yyjson_type ctn_type; bool idx_is_last = false; /* skip exist parent nodes */ while (true) { token = ptr_next_token(&ptr, end, &token_len, &esc); if (unlikely(!token)) return_err_syntax(false, ptr - hdr); ctn = val; ctn_type = unsafe_yyjson_get_type(ctn); if (ctn_type == YYJSON_TYPE_OBJ) { val = ptr_mut_obj_get(ctn, token, token_len, esc, &pre); } else if (ctn_type == YYJSON_TYPE_ARR) { val = ptr_mut_arr_get(ctn, token, token_len, esc, &pre, &idx_is_last); } else return_err_resolve(false, token - hdr); if (!val) break; if (ptr == end) break; /* is last token */ } /* create parent nodes if not exist */ if (unlikely(ptr != end)) { /* not last token */ if (!create_parent) return_err_resolve(false, token - hdr); /* add value at last index if container is array */ if (ctn_type == YYJSON_TYPE_ARR) { if (!idx_is_last || !insert_new) { return_err_resolve(false, token - hdr); } val = yyjson_mut_obj(doc); if (!val) return_err_alloc(false); /* delay attaching until all operations are completed */ sep_ctn = ctn; sep_key = NULL; sep_val = val; /* move to next token */ ctn = val; val = NULL; ctn_type = YYJSON_TYPE_OBJ; token = ptr_next_token(&ptr, end, &token_len, &esc); if (unlikely(!token)) return_err_resolve(false, token - hdr); } /* container is object, create parent nodes */ while (ptr != end) { /* not last token */ key = ptr_new_key(token, token_len, esc, doc); if (!key) return_err_alloc(false); val = yyjson_mut_obj(doc); if (!val) return_err_alloc(false); /* delay attaching until all operations are completed */ if (!sep_ctn) { sep_ctn = ctn; sep_key = key; sep_val = val; } else { yyjson_mut_obj_add(ctn, key, val); } /* move to next token */ ctn = val; val = NULL; token = ptr_next_token(&ptr, end, &token_len, &esc); if (unlikely(!token)) return_err_syntax(false, ptr - hdr); } } /* JSON pointer is resolved, insert or replace target value */ ctn_len = unsafe_yyjson_get_len(ctn); if (ctn_type == YYJSON_TYPE_OBJ) { if (ctx) ctx->ctn = ctn; if (!val || insert_new) { /* insert new key-value pair */ key = ptr_new_key(token, token_len, esc, doc); if (unlikely(!key)) return_err_alloc(false); if (ctx) ctx->pre = ctn_len ? (yyjson_mut_val *)ctn->uni.ptr : key; unsafe_yyjson_mut_obj_add(ctn, key, new_val, ctn_len); } else { /* replace exist value */ key = pre->next->next; if (ctx) ctx->pre = pre; if (ctx) ctx->old = val; yyjson_mut_obj_put(ctn, key, new_val); } } else { /* array */ if (ctx && (val || idx_is_last)) ctx->ctn = ctn; if (insert_new) { /* append new value */ if (val) { pre->next = new_val; new_val->next = val; if (ctx) ctx->pre = pre; unsafe_yyjson_set_len(ctn, ctn_len + 1); } else if (idx_is_last) { if (ctx) ctx->pre = ctn_len ? (yyjson_mut_val *)ctn->uni.ptr : new_val; yyjson_mut_arr_append(ctn, new_val); } else { return_err_resolve(false, token - hdr); } } else { /* replace exist value */ if (!val) return_err_resolve(false, token - hdr); if (ctn_len > 1) { new_val->next = val->next; pre->next = new_val; if (ctn->uni.ptr == val) ctn->uni.ptr = new_val; } else { new_val->next = new_val; ctn->uni.ptr = new_val; pre = new_val; } if (ctx) ctx->pre = pre; if (ctx) ctx->old = val; } } /* all operations are completed, attach the new components to the target */ if (unlikely(sep_ctn)) { if (sep_key) yyjson_mut_obj_add(sep_ctn, sep_key, sep_val); else yyjson_mut_arr_append(sep_ctn, sep_val); } return true; } yyjson_mut_val *unsafe_yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_mut_val *cur_val; yyjson_ptr_ctx cur_ctx; memset(&cur_ctx, 0, sizeof(cur_ctx)); if (!ctx) ctx = &cur_ctx; cur_val = unsafe_yyjson_mut_ptr_getx(val, ptr, len, ctx, err); if (!cur_val) return NULL; if (yyjson_mut_is_obj(ctx->ctn)) { yyjson_mut_val *key = ctx->pre->next->next; yyjson_mut_obj_put(ctx->ctn, key, new_val); } else { yyjson_ptr_ctx_replace(ctx, new_val); } ctx->old = cur_val; return cur_val; } yyjson_mut_val *unsafe_yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_mut_val *cur_val; yyjson_ptr_ctx cur_ctx; memset(&cur_ctx, 0, sizeof(cur_ctx)); if (!ctx) ctx = &cur_ctx; cur_val = unsafe_yyjson_mut_ptr_getx(val, ptr, len, ctx, err); if (cur_val) { if (yyjson_mut_is_obj(ctx->ctn)) { yyjson_mut_val *key = ctx->pre->next->next; yyjson_mut_obj_put(ctx->ctn, key, NULL); } else { yyjson_ptr_ctx_remove(ctx); } ctx->pre = NULL; ctx->old = cur_val; } return cur_val; } /* macros for yyjson_ptr */ #undef return_err #undef return_err_resolve #undef return_err_syntax #undef return_err_alloc /*============================================================================== * JSON Patch API (RFC 6902) *============================================================================*/ /* JSON Patch operation */ typedef enum patch_op { PATCH_OP_ADD, /* path, value */ PATCH_OP_REMOVE, /* path */ PATCH_OP_REPLACE, /* path, value */ PATCH_OP_MOVE, /* from, path */ PATCH_OP_COPY, /* from, path */ PATCH_OP_TEST, /* path, value */ PATCH_OP_NONE /* invalid */ } patch_op; static patch_op patch_op_get(yyjson_val *op) { const char *str = op->uni.str; switch (unsafe_yyjson_get_len(op)) { case 3: if (!memcmp(str, "add", 3)) return PATCH_OP_ADD; return PATCH_OP_NONE; case 4: if (!memcmp(str, "move", 4)) return PATCH_OP_MOVE; if (!memcmp(str, "copy", 4)) return PATCH_OP_COPY; if (!memcmp(str, "test", 4)) return PATCH_OP_TEST; return PATCH_OP_NONE; case 6: if (!memcmp(str, "remove", 6)) return PATCH_OP_REMOVE; return PATCH_OP_NONE; case 7: if (!memcmp(str, "replace", 7)) return PATCH_OP_REPLACE; return PATCH_OP_NONE; default: return PATCH_OP_NONE; } } /* macros for yyjson_patch */ #define return_err(_code, _msg) do { \ if (err->ptr.code == YYJSON_PTR_ERR_MEMORY_ALLOCATION) { \ err->code = YYJSON_PATCH_ERROR_MEMORY_ALLOCATION; \ err->msg = _msg; \ memset(&err->ptr, 0, sizeof(yyjson_ptr_err)); \ } else { \ err->code = YYJSON_PATCH_ERROR_##_code; \ err->msg = _msg; \ err->idx = iter.idx ? iter.idx - 1 : 0; \ } \ return NULL; \ } while (false) #define return_err_copy() \ return_err(MEMORY_ALLOCATION, "failed to copy value") #define return_err_key(_key) \ return_err(MISSING_KEY, "missing key " _key) #define return_err_val(_key) \ return_err(INVALID_MEMBER, "invalid member " _key) #define ptr_get(_ptr) yyjson_mut_ptr_getx( \ root, _ptr->uni.str, _ptr##_len, NULL, &err->ptr) #define ptr_add(_ptr, _val) yyjson_mut_ptr_addx( \ root, _ptr->uni.str, _ptr##_len, _val, doc, false, NULL, &err->ptr) #define ptr_remove(_ptr) yyjson_mut_ptr_removex( \ root, _ptr->uni.str, _ptr##_len, NULL, &err->ptr) #define ptr_replace(_ptr, _val)yyjson_mut_ptr_replacex( \ root, _ptr->uni.str, _ptr##_len, _val, NULL, &err->ptr) yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch, yyjson_patch_err *err) { yyjson_mut_val *root; yyjson_val *obj; yyjson_arr_iter iter; yyjson_patch_err err_tmp; if (!err) err = &err_tmp; memset(err, 0, sizeof(*err)); memset(&iter, 0, sizeof(iter)); if (unlikely(!doc || !orig || !patch)) { return_err(INVALID_PARAMETER, "input parameter is NULL"); } if (unlikely(!yyjson_is_arr(patch))) { return_err(INVALID_PARAMETER, "input patch is not array"); } root = yyjson_val_mut_copy(doc, orig); if (unlikely(!root)) return_err_copy(); /* iterate through the patch array */ yyjson_arr_iter_init(patch, &iter); while ((obj = yyjson_arr_iter_next(&iter))) { patch_op op_enum; yyjson_val *op, *path, *from = NULL, *value; yyjson_mut_val *val = NULL, *test; usize path_len, from_len = 0; if (unlikely(!unsafe_yyjson_is_obj(obj))) { return_err(INVALID_OPERATION, "JSON patch operation is not object"); } /* get required member: op */ op = yyjson_obj_get(obj, "op"); if (unlikely(!op)) return_err_key("`op`"); if (unlikely(!yyjson_is_str(op))) return_err_val("`op`"); op_enum = patch_op_get(op); /* get required member: path */ path = yyjson_obj_get(obj, "path"); if (unlikely(!path)) return_err_key("`path`"); if (unlikely(!yyjson_is_str(path))) return_err_val("`path`"); path_len = unsafe_yyjson_get_len(path); /* get required member: value, from */ switch ((int)op_enum) { case PATCH_OP_ADD: case PATCH_OP_REPLACE: case PATCH_OP_TEST: value = yyjson_obj_get(obj, "value"); if (unlikely(!value)) return_err_key("`value`"); val = yyjson_val_mut_copy(doc, value); if (unlikely(!val)) return_err_copy(); break; case PATCH_OP_MOVE: case PATCH_OP_COPY: from = yyjson_obj_get(obj, "from"); if (unlikely(!from)) return_err_key("`from`"); if (unlikely(!yyjson_is_str(from))) return_err_val("`from`"); from_len = unsafe_yyjson_get_len(from); break; default: break; } /* perform an operation */ switch ((int)op_enum) { case PATCH_OP_ADD: /* add(path, val) */ if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_REMOVE: /* remove(path) */ if (unlikely(!ptr_remove(path))) { return_err(POINTER, "failed to remove `path`"); } break; case PATCH_OP_REPLACE: /* replace(path, val) */ if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_replace(path, val))) { return_err(POINTER, "failed to replace `path`"); } break; case PATCH_OP_MOVE: /* val = remove(from), add(path, val) */ if (unlikely(from_len == 0 && path_len == 0)) break; val = ptr_remove(from); if (unlikely(!val)) { return_err(POINTER, "failed to remove `from`"); } if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_COPY: /* val = get(from).copy, add(path, val) */ val = ptr_get(from); if (unlikely(!val)) { return_err(POINTER, "failed to get `from`"); } if (unlikely(path_len == 0)) { root = val; break; } val = yyjson_mut_val_mut_copy(doc, val); if (unlikely(!val)) return_err_copy(); if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_TEST: /* test = get(path), test.eq(val) */ test = ptr_get(path); if (unlikely(!test)) { return_err(POINTER, "failed to get `path`"); } if (unlikely(!yyjson_mut_equals(val, test))) { return_err(EQUAL, "failed to test equal"); } break; default: return_err(INVALID_MEMBER, "unsupported `op`"); } } return root; } yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch, yyjson_patch_err *err) { yyjson_mut_val *root, *obj; yyjson_mut_arr_iter iter; yyjson_patch_err err_tmp; if (!err) err = &err_tmp; memset(err, 0, sizeof(*err)); memset(&iter, 0, sizeof(iter)); if (unlikely(!doc || !orig || !patch)) { return_err(INVALID_PARAMETER, "input parameter is NULL"); } if (unlikely(!yyjson_mut_is_arr(patch))) { return_err(INVALID_PARAMETER, "input patch is not array"); } root = yyjson_mut_val_mut_copy(doc, orig); if (unlikely(!root)) return_err_copy(); /* iterate through the patch array */ yyjson_mut_arr_iter_init(patch, &iter); while ((obj = yyjson_mut_arr_iter_next(&iter))) { patch_op op_enum; yyjson_mut_val *op, *path, *from = NULL, *value; yyjson_mut_val *val = NULL, *test; usize path_len, from_len = 0; if (!unsafe_yyjson_is_obj(obj)) { return_err(INVALID_OPERATION, "JSON patch operation is not object"); } /* get required member: op */ op = yyjson_mut_obj_get(obj, "op"); if (unlikely(!op)) return_err_key("`op`"); if (unlikely(!yyjson_mut_is_str(op))) return_err_val("`op`"); op_enum = patch_op_get((yyjson_val *)(void *)op); /* get required member: path */ path = yyjson_mut_obj_get(obj, "path"); if (unlikely(!path)) return_err_key("`path`"); if (unlikely(!yyjson_mut_is_str(path))) return_err_val("`path`"); path_len = unsafe_yyjson_get_len(path); /* get required member: value, from */ switch ((int)op_enum) { case PATCH_OP_ADD: case PATCH_OP_REPLACE: case PATCH_OP_TEST: value = yyjson_mut_obj_get(obj, "value"); if (unlikely(!value)) return_err_key("`value`"); val = yyjson_mut_val_mut_copy(doc, value); if (unlikely(!val)) return_err_copy(); break; case PATCH_OP_MOVE: case PATCH_OP_COPY: from = yyjson_mut_obj_get(obj, "from"); if (unlikely(!from)) return_err_key("`from`"); if (unlikely(!yyjson_mut_is_str(from))) { return_err_val("`from`"); } from_len = unsafe_yyjson_get_len(from); break; default: break; } /* perform an operation */ switch ((int)op_enum) { case PATCH_OP_ADD: /* add(path, val) */ if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_REMOVE: /* remove(path) */ if (unlikely(!ptr_remove(path))) { return_err(POINTER, "failed to remove `path`"); } break; case PATCH_OP_REPLACE: /* replace(path, val) */ if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_replace(path, val))) { return_err(POINTER, "failed to replace `path`"); } break; case PATCH_OP_MOVE: /* val = remove(from), add(path, val) */ if (unlikely(from_len == 0 && path_len == 0)) break; val = ptr_remove(from); if (unlikely(!val)) { return_err(POINTER, "failed to remove `from`"); } if (unlikely(path_len == 0)) { root = val; break; } if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_COPY: /* val = get(from).copy, add(path, val) */ val = ptr_get(from); if (unlikely(!val)) { return_err(POINTER, "failed to get `from`"); } if (unlikely(path_len == 0)) { root = val; break; } val = yyjson_mut_val_mut_copy(doc, val); if (unlikely(!val)) return_err_copy(); if (unlikely(!ptr_add(path, val))) { return_err(POINTER, "failed to add `path`"); } break; case PATCH_OP_TEST: /* test = get(path), test.eq(val) */ test = ptr_get(path); if (unlikely(!test)) { return_err(POINTER, "failed to get `path`"); } if (unlikely(!yyjson_mut_equals(val, test))) { return_err(EQUAL, "failed to test equal"); } break; default: return_err(INVALID_MEMBER, "unsupported `op`"); } } return root; } /* macros for yyjson_patch */ #undef return_err #undef return_err_copy #undef return_err_key #undef return_err_val #undef ptr_get #undef ptr_add #undef ptr_remove #undef ptr_replace /*============================================================================== * JSON Merge-Patch API (RFC 7386) *============================================================================*/ yyjson_mut_val *yyjson_merge_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch) { usize idx, max; yyjson_val *key, *orig_val, *patch_val, local_orig; yyjson_mut_val *builder, *mut_key, *mut_val, *merged_val; if (unlikely(!yyjson_is_obj(patch))) { return yyjson_val_mut_copy(doc, patch); } builder = yyjson_mut_obj(doc); if (unlikely(!builder)) return NULL; memset(&local_orig, 0, sizeof(local_orig)); if (!yyjson_is_obj(orig)) { orig = &local_orig; orig->tag = builder->tag; orig->uni = builder->uni; } /* If orig is contributing, copy any items not modified by the patch */ if (orig != &local_orig) { yyjson_obj_foreach(orig, idx, max, key, orig_val) { patch_val = yyjson_obj_getn(patch, unsafe_yyjson_get_str(key), unsafe_yyjson_get_len(key)); if (!patch_val) { mut_key = yyjson_val_mut_copy(doc, key); mut_val = yyjson_val_mut_copy(doc, orig_val); if (!yyjson_mut_obj_add(builder, mut_key, mut_val)) return NULL; } } } /* Merge items modified by the patch. */ yyjson_obj_foreach(patch, idx, max, key, patch_val) { /* null indicates the field is removed. */ if (unsafe_yyjson_is_null(patch_val)) { continue; } mut_key = yyjson_val_mut_copy(doc, key); orig_val = yyjson_obj_getn(orig, unsafe_yyjson_get_str(key), unsafe_yyjson_get_len(key)); merged_val = yyjson_merge_patch(doc, orig_val, patch_val); if (!yyjson_mut_obj_add(builder, mut_key, merged_val)) return NULL; } return builder; } yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch) { usize idx, max; yyjson_mut_val *key, *orig_val, *patch_val, local_orig; yyjson_mut_val *builder, *mut_key, *mut_val, *merged_val; if (unlikely(!yyjson_mut_is_obj(patch))) { return yyjson_mut_val_mut_copy(doc, patch); } builder = yyjson_mut_obj(doc); if (unlikely(!builder)) return NULL; memset(&local_orig, 0, sizeof(local_orig)); if (!yyjson_mut_is_obj(orig)) { orig = &local_orig; orig->tag = builder->tag; orig->uni = builder->uni; } /* If orig is contributing, copy any items not modified by the patch */ if (orig != &local_orig) { yyjson_mut_obj_foreach(orig, idx, max, key, orig_val) { patch_val = yyjson_mut_obj_getn(patch, unsafe_yyjson_get_str(key), unsafe_yyjson_get_len(key)); if (!patch_val) { mut_key = yyjson_mut_val_mut_copy(doc, key); mut_val = yyjson_mut_val_mut_copy(doc, orig_val); if (!yyjson_mut_obj_add(builder, mut_key, mut_val)) return NULL; } } } /* Merge items modified by the patch. */ yyjson_mut_obj_foreach(patch, idx, max, key, patch_val) { /* null indicates the field is removed. */ if (unsafe_yyjson_is_null(patch_val)) { continue; } mut_key = yyjson_mut_val_mut_copy(doc, key); orig_val = yyjson_mut_obj_getn(orig, unsafe_yyjson_get_str(key), unsafe_yyjson_get_len(key)); merged_val = yyjson_mut_merge_patch(doc, orig_val, patch_val); if (!yyjson_mut_obj_add(builder, mut_key, merged_val)) return NULL; } return builder; } #endif /* YYJSON_DISABLE_UTILS */ /*============================================================================== * Power10 Lookup Table * These data are used by the floating-point number reader and writer. *============================================================================*/ #if (!YYJSON_DISABLE_READER || !YYJSON_DISABLE_WRITER) && \ (!YYJSON_DISABLE_FAST_FP_CONV) /** Minimum decimal exponent in pow10_sig_table. */ #define POW10_SIG_TABLE_MIN_EXP -343 /** Maximum decimal exponent in pow10_sig_table. */ #define POW10_SIG_TABLE_MAX_EXP 324 /** Minimum exact decimal exponent in pow10_sig_table */ #define POW10_SIG_TABLE_MIN_EXACT_EXP 0 /** Maximum exact decimal exponent in pow10_sig_table */ #define POW10_SIG_TABLE_MAX_EXACT_EXP 55 /** Normalized significant 128 bits of pow10, no rounded up (size: 10.4KB). This lookup table is used by both the double number reader and writer. (generate with misc/make_tables.c) */ static const u64 pow10_sig_table[] = { U64(0xBF29DCAB, 0xA82FDEAE), U64(0x7432EE87, 0x3880FC33), /* ~= 10^-343 */ U64(0xEEF453D6, 0x923BD65A), U64(0x113FAA29, 0x06A13B3F), /* ~= 10^-342 */ U64(0x9558B466, 0x1B6565F8), U64(0x4AC7CA59, 0xA424C507), /* ~= 10^-341 */ U64(0xBAAEE17F, 0xA23EBF76), U64(0x5D79BCF0, 0x0D2DF649), /* ~= 10^-340 */ U64(0xE95A99DF, 0x8ACE6F53), U64(0xF4D82C2C, 0x107973DC), /* ~= 10^-339 */ U64(0x91D8A02B, 0xB6C10594), U64(0x79071B9B, 0x8A4BE869), /* ~= 10^-338 */ U64(0xB64EC836, 0xA47146F9), U64(0x9748E282, 0x6CDEE284), /* ~= 10^-337 */ U64(0xE3E27A44, 0x4D8D98B7), U64(0xFD1B1B23, 0x08169B25), /* ~= 10^-336 */ U64(0x8E6D8C6A, 0xB0787F72), U64(0xFE30F0F5, 0xE50E20F7), /* ~= 10^-335 */ U64(0xB208EF85, 0x5C969F4F), U64(0xBDBD2D33, 0x5E51A935), /* ~= 10^-334 */ U64(0xDE8B2B66, 0xB3BC4723), U64(0xAD2C7880, 0x35E61382), /* ~= 10^-333 */ U64(0x8B16FB20, 0x3055AC76), U64(0x4C3BCB50, 0x21AFCC31), /* ~= 10^-332 */ U64(0xADDCB9E8, 0x3C6B1793), U64(0xDF4ABE24, 0x2A1BBF3D), /* ~= 10^-331 */ U64(0xD953E862, 0x4B85DD78), U64(0xD71D6DAD, 0x34A2AF0D), /* ~= 10^-330 */ U64(0x87D4713D, 0x6F33AA6B), U64(0x8672648C, 0x40E5AD68), /* ~= 10^-329 */ U64(0xA9C98D8C, 0xCB009506), U64(0x680EFDAF, 0x511F18C2), /* ~= 10^-328 */ U64(0xD43BF0EF, 0xFDC0BA48), U64(0x0212BD1B, 0x2566DEF2), /* ~= 10^-327 */ U64(0x84A57695, 0xFE98746D), U64(0x014BB630, 0xF7604B57), /* ~= 10^-326 */ U64(0xA5CED43B, 0x7E3E9188), U64(0x419EA3BD, 0x35385E2D), /* ~= 10^-325 */ U64(0xCF42894A, 0x5DCE35EA), U64(0x52064CAC, 0x828675B9), /* ~= 10^-324 */ U64(0x818995CE, 0x7AA0E1B2), U64(0x7343EFEB, 0xD1940993), /* ~= 10^-323 */ U64(0xA1EBFB42, 0x19491A1F), U64(0x1014EBE6, 0xC5F90BF8), /* ~= 10^-322 */ U64(0xCA66FA12, 0x9F9B60A6), U64(0xD41A26E0, 0x77774EF6), /* ~= 10^-321 */ U64(0xFD00B897, 0x478238D0), U64(0x8920B098, 0x955522B4), /* ~= 10^-320 */ U64(0x9E20735E, 0x8CB16382), U64(0x55B46E5F, 0x5D5535B0), /* ~= 10^-319 */ U64(0xC5A89036, 0x2FDDBC62), U64(0xEB2189F7, 0x34AA831D), /* ~= 10^-318 */ U64(0xF712B443, 0xBBD52B7B), U64(0xA5E9EC75, 0x01D523E4), /* ~= 10^-317 */ U64(0x9A6BB0AA, 0x55653B2D), U64(0x47B233C9, 0x2125366E), /* ~= 10^-316 */ U64(0xC1069CD4, 0xEABE89F8), U64(0x999EC0BB, 0x696E840A), /* ~= 10^-315 */ U64(0xF148440A, 0x256E2C76), U64(0xC00670EA, 0x43CA250D), /* ~= 10^-314 */ U64(0x96CD2A86, 0x5764DBCA), U64(0x38040692, 0x6A5E5728), /* ~= 10^-313 */ U64(0xBC807527, 0xED3E12BC), U64(0xC6050837, 0x04F5ECF2), /* ~= 10^-312 */ U64(0xEBA09271, 0xE88D976B), U64(0xF7864A44, 0xC633682E), /* ~= 10^-311 */ U64(0x93445B87, 0x31587EA3), U64(0x7AB3EE6A, 0xFBE0211D), /* ~= 10^-310 */ U64(0xB8157268, 0xFDAE9E4C), U64(0x5960EA05, 0xBAD82964), /* ~= 10^-309 */ U64(0xE61ACF03, 0x3D1A45DF), U64(0x6FB92487, 0x298E33BD), /* ~= 10^-308 */ U64(0x8FD0C162, 0x06306BAB), U64(0xA5D3B6D4, 0x79F8E056), /* ~= 10^-307 */ U64(0xB3C4F1BA, 0x87BC8696), U64(0x8F48A489, 0x9877186C), /* ~= 10^-306 */ U64(0xE0B62E29, 0x29ABA83C), U64(0x331ACDAB, 0xFE94DE87), /* ~= 10^-305 */ U64(0x8C71DCD9, 0xBA0B4925), U64(0x9FF0C08B, 0x7F1D0B14), /* ~= 10^-304 */ U64(0xAF8E5410, 0x288E1B6F), U64(0x07ECF0AE, 0x5EE44DD9), /* ~= 10^-303 */ U64(0xDB71E914, 0x32B1A24A), U64(0xC9E82CD9, 0xF69D6150), /* ~= 10^-302 */ U64(0x892731AC, 0x9FAF056E), U64(0xBE311C08, 0x3A225CD2), /* ~= 10^-301 */ U64(0xAB70FE17, 0xC79AC6CA), U64(0x6DBD630A, 0x48AAF406), /* ~= 10^-300 */ U64(0xD64D3D9D, 0xB981787D), U64(0x092CBBCC, 0xDAD5B108), /* ~= 10^-299 */ U64(0x85F04682, 0x93F0EB4E), U64(0x25BBF560, 0x08C58EA5), /* ~= 10^-298 */ U64(0xA76C5823, 0x38ED2621), U64(0xAF2AF2B8, 0x0AF6F24E), /* ~= 10^-297 */ U64(0xD1476E2C, 0x07286FAA), U64(0x1AF5AF66, 0x0DB4AEE1), /* ~= 10^-296 */ U64(0x82CCA4DB, 0x847945CA), U64(0x50D98D9F, 0xC890ED4D), /* ~= 10^-295 */ U64(0xA37FCE12, 0x6597973C), U64(0xE50FF107, 0xBAB528A0), /* ~= 10^-294 */ U64(0xCC5FC196, 0xFEFD7D0C), U64(0x1E53ED49, 0xA96272C8), /* ~= 10^-293 */ U64(0xFF77B1FC, 0xBEBCDC4F), U64(0x25E8E89C, 0x13BB0F7A), /* ~= 10^-292 */ U64(0x9FAACF3D, 0xF73609B1), U64(0x77B19161, 0x8C54E9AC), /* ~= 10^-291 */ U64(0xC795830D, 0x75038C1D), U64(0xD59DF5B9, 0xEF6A2417), /* ~= 10^-290 */ U64(0xF97AE3D0, 0xD2446F25), U64(0x4B057328, 0x6B44AD1D), /* ~= 10^-289 */ U64(0x9BECCE62, 0x836AC577), U64(0x4EE367F9, 0x430AEC32), /* ~= 10^-288 */ U64(0xC2E801FB, 0x244576D5), U64(0x229C41F7, 0x93CDA73F), /* ~= 10^-287 */ U64(0xF3A20279, 0xED56D48A), U64(0x6B435275, 0x78C1110F), /* ~= 10^-286 */ U64(0x9845418C, 0x345644D6), U64(0x830A1389, 0x6B78AAA9), /* ~= 10^-285 */ U64(0xBE5691EF, 0x416BD60C), U64(0x23CC986B, 0xC656D553), /* ~= 10^-284 */ U64(0xEDEC366B, 0x11C6CB8F), U64(0x2CBFBE86, 0xB7EC8AA8), /* ~= 10^-283 */ U64(0x94B3A202, 0xEB1C3F39), U64(0x7BF7D714, 0x32F3D6A9), /* ~= 10^-282 */ U64(0xB9E08A83, 0xA5E34F07), U64(0xDAF5CCD9, 0x3FB0CC53), /* ~= 10^-281 */ U64(0xE858AD24, 0x8F5C22C9), U64(0xD1B3400F, 0x8F9CFF68), /* ~= 10^-280 */ U64(0x91376C36, 0xD99995BE), U64(0x23100809, 0xB9C21FA1), /* ~= 10^-279 */ U64(0xB5854744, 0x8FFFFB2D), U64(0xABD40A0C, 0x2832A78A), /* ~= 10^-278 */ U64(0xE2E69915, 0xB3FFF9F9), U64(0x16C90C8F, 0x323F516C), /* ~= 10^-277 */ U64(0x8DD01FAD, 0x907FFC3B), U64(0xAE3DA7D9, 0x7F6792E3), /* ~= 10^-276 */ U64(0xB1442798, 0xF49FFB4A), U64(0x99CD11CF, 0xDF41779C), /* ~= 10^-275 */ U64(0xDD95317F, 0x31C7FA1D), U64(0x40405643, 0xD711D583), /* ~= 10^-274 */ U64(0x8A7D3EEF, 0x7F1CFC52), U64(0x482835EA, 0x666B2572), /* ~= 10^-273 */ U64(0xAD1C8EAB, 0x5EE43B66), U64(0xDA324365, 0x0005EECF), /* ~= 10^-272 */ U64(0xD863B256, 0x369D4A40), U64(0x90BED43E, 0x40076A82), /* ~= 10^-271 */ U64(0x873E4F75, 0xE2224E68), U64(0x5A7744A6, 0xE804A291), /* ~= 10^-270 */ U64(0xA90DE353, 0x5AAAE202), U64(0x711515D0, 0xA205CB36), /* ~= 10^-269 */ U64(0xD3515C28, 0x31559A83), U64(0x0D5A5B44, 0xCA873E03), /* ~= 10^-268 */ U64(0x8412D999, 0x1ED58091), U64(0xE858790A, 0xFE9486C2), /* ~= 10^-267 */ U64(0xA5178FFF, 0x668AE0B6), U64(0x626E974D, 0xBE39A872), /* ~= 10^-266 */ U64(0xCE5D73FF, 0x402D98E3), U64(0xFB0A3D21, 0x2DC8128F), /* ~= 10^-265 */ U64(0x80FA687F, 0x881C7F8E), U64(0x7CE66634, 0xBC9D0B99), /* ~= 10^-264 */ U64(0xA139029F, 0x6A239F72), U64(0x1C1FFFC1, 0xEBC44E80), /* ~= 10^-263 */ U64(0xC9874347, 0x44AC874E), U64(0xA327FFB2, 0x66B56220), /* ~= 10^-262 */ U64(0xFBE91419, 0x15D7A922), U64(0x4BF1FF9F, 0x0062BAA8), /* ~= 10^-261 */ U64(0x9D71AC8F, 0xADA6C9B5), U64(0x6F773FC3, 0x603DB4A9), /* ~= 10^-260 */ U64(0xC4CE17B3, 0x99107C22), U64(0xCB550FB4, 0x384D21D3), /* ~= 10^-259 */ U64(0xF6019DA0, 0x7F549B2B), U64(0x7E2A53A1, 0x46606A48), /* ~= 10^-258 */ U64(0x99C10284, 0x4F94E0FB), U64(0x2EDA7444, 0xCBFC426D), /* ~= 10^-257 */ U64(0xC0314325, 0x637A1939), U64(0xFA911155, 0xFEFB5308), /* ~= 10^-256 */ U64(0xF03D93EE, 0xBC589F88), U64(0x793555AB, 0x7EBA27CA), /* ~= 10^-255 */ U64(0x96267C75, 0x35B763B5), U64(0x4BC1558B, 0x2F3458DE), /* ~= 10^-254 */ U64(0xBBB01B92, 0x83253CA2), U64(0x9EB1AAED, 0xFB016F16), /* ~= 10^-253 */ U64(0xEA9C2277, 0x23EE8BCB), U64(0x465E15A9, 0x79C1CADC), /* ~= 10^-252 */ U64(0x92A1958A, 0x7675175F), U64(0x0BFACD89, 0xEC191EC9), /* ~= 10^-251 */ U64(0xB749FAED, 0x14125D36), U64(0xCEF980EC, 0x671F667B), /* ~= 10^-250 */ U64(0xE51C79A8, 0x5916F484), U64(0x82B7E127, 0x80E7401A), /* ~= 10^-249 */ U64(0x8F31CC09, 0x37AE58D2), U64(0xD1B2ECB8, 0xB0908810), /* ~= 10^-248 */ U64(0xB2FE3F0B, 0x8599EF07), U64(0x861FA7E6, 0xDCB4AA15), /* ~= 10^-247 */ U64(0xDFBDCECE, 0x67006AC9), U64(0x67A791E0, 0x93E1D49A), /* ~= 10^-246 */ U64(0x8BD6A141, 0x006042BD), U64(0xE0C8BB2C, 0x5C6D24E0), /* ~= 10^-245 */ U64(0xAECC4991, 0x4078536D), U64(0x58FAE9F7, 0x73886E18), /* ~= 10^-244 */ U64(0xDA7F5BF5, 0x90966848), U64(0xAF39A475, 0x506A899E), /* ~= 10^-243 */ U64(0x888F9979, 0x7A5E012D), U64(0x6D8406C9, 0x52429603), /* ~= 10^-242 */ U64(0xAAB37FD7, 0xD8F58178), U64(0xC8E5087B, 0xA6D33B83), /* ~= 10^-241 */ U64(0xD5605FCD, 0xCF32E1D6), U64(0xFB1E4A9A, 0x90880A64), /* ~= 10^-240 */ U64(0x855C3BE0, 0xA17FCD26), U64(0x5CF2EEA0, 0x9A55067F), /* ~= 10^-239 */ U64(0xA6B34AD8, 0xC9DFC06F), U64(0xF42FAA48, 0xC0EA481E), /* ~= 10^-238 */ U64(0xD0601D8E, 0xFC57B08B), U64(0xF13B94DA, 0xF124DA26), /* ~= 10^-237 */ U64(0x823C1279, 0x5DB6CE57), U64(0x76C53D08, 0xD6B70858), /* ~= 10^-236 */ U64(0xA2CB1717, 0xB52481ED), U64(0x54768C4B, 0x0C64CA6E), /* ~= 10^-235 */ U64(0xCB7DDCDD, 0xA26DA268), U64(0xA9942F5D, 0xCF7DFD09), /* ~= 10^-234 */ U64(0xFE5D5415, 0x0B090B02), U64(0xD3F93B35, 0x435D7C4C), /* ~= 10^-233 */ U64(0x9EFA548D, 0x26E5A6E1), U64(0xC47BC501, 0x4A1A6DAF), /* ~= 10^-232 */ U64(0xC6B8E9B0, 0x709F109A), U64(0x359AB641, 0x9CA1091B), /* ~= 10^-231 */ U64(0xF867241C, 0x8CC6D4C0), U64(0xC30163D2, 0x03C94B62), /* ~= 10^-230 */ U64(0x9B407691, 0xD7FC44F8), U64(0x79E0DE63, 0x425DCF1D), /* ~= 10^-229 */ U64(0xC2109436, 0x4DFB5636), U64(0x985915FC, 0x12F542E4), /* ~= 10^-228 */ U64(0xF294B943, 0xE17A2BC4), U64(0x3E6F5B7B, 0x17B2939D), /* ~= 10^-227 */ U64(0x979CF3CA, 0x6CEC5B5A), U64(0xA705992C, 0xEECF9C42), /* ~= 10^-226 */ U64(0xBD8430BD, 0x08277231), U64(0x50C6FF78, 0x2A838353), /* ~= 10^-225 */ U64(0xECE53CEC, 0x4A314EBD), U64(0xA4F8BF56, 0x35246428), /* ~= 10^-224 */ U64(0x940F4613, 0xAE5ED136), U64(0x871B7795, 0xE136BE99), /* ~= 10^-223 */ U64(0xB9131798, 0x99F68584), U64(0x28E2557B, 0x59846E3F), /* ~= 10^-222 */ U64(0xE757DD7E, 0xC07426E5), U64(0x331AEADA, 0x2FE589CF), /* ~= 10^-221 */ U64(0x9096EA6F, 0x3848984F), U64(0x3FF0D2C8, 0x5DEF7621), /* ~= 10^-220 */ U64(0xB4BCA50B, 0x065ABE63), U64(0x0FED077A, 0x756B53A9), /* ~= 10^-219 */ U64(0xE1EBCE4D, 0xC7F16DFB), U64(0xD3E84959, 0x12C62894), /* ~= 10^-218 */ U64(0x8D3360F0, 0x9CF6E4BD), U64(0x64712DD7, 0xABBBD95C), /* ~= 10^-217 */ U64(0xB080392C, 0xC4349DEC), U64(0xBD8D794D, 0x96AACFB3), /* ~= 10^-216 */ U64(0xDCA04777, 0xF541C567), U64(0xECF0D7A0, 0xFC5583A0), /* ~= 10^-215 */ U64(0x89E42CAA, 0xF9491B60), U64(0xF41686C4, 0x9DB57244), /* ~= 10^-214 */ U64(0xAC5D37D5, 0xB79B6239), U64(0x311C2875, 0xC522CED5), /* ~= 10^-213 */ U64(0xD77485CB, 0x25823AC7), U64(0x7D633293, 0x366B828B), /* ~= 10^-212 */ U64(0x86A8D39E, 0xF77164BC), U64(0xAE5DFF9C, 0x02033197), /* ~= 10^-211 */ U64(0xA8530886, 0xB54DBDEB), U64(0xD9F57F83, 0x0283FDFC), /* ~= 10^-210 */ U64(0xD267CAA8, 0x62A12D66), U64(0xD072DF63, 0xC324FD7B), /* ~= 10^-209 */ U64(0x8380DEA9, 0x3DA4BC60), U64(0x4247CB9E, 0x59F71E6D), /* ~= 10^-208 */ U64(0xA4611653, 0x8D0DEB78), U64(0x52D9BE85, 0xF074E608), /* ~= 10^-207 */ U64(0xCD795BE8, 0x70516656), U64(0x67902E27, 0x6C921F8B), /* ~= 10^-206 */ U64(0x806BD971, 0x4632DFF6), U64(0x00BA1CD8, 0xA3DB53B6), /* ~= 10^-205 */ U64(0xA086CFCD, 0x97BF97F3), U64(0x80E8A40E, 0xCCD228A4), /* ~= 10^-204 */ U64(0xC8A883C0, 0xFDAF7DF0), U64(0x6122CD12, 0x8006B2CD), /* ~= 10^-203 */ U64(0xFAD2A4B1, 0x3D1B5D6C), U64(0x796B8057, 0x20085F81), /* ~= 10^-202 */ U64(0x9CC3A6EE, 0xC6311A63), U64(0xCBE33036, 0x74053BB0), /* ~= 10^-201 */ U64(0xC3F490AA, 0x77BD60FC), U64(0xBEDBFC44, 0x11068A9C), /* ~= 10^-200 */ U64(0xF4F1B4D5, 0x15ACB93B), U64(0xEE92FB55, 0x15482D44), /* ~= 10^-199 */ U64(0x99171105, 0x2D8BF3C5), U64(0x751BDD15, 0x2D4D1C4A), /* ~= 10^-198 */ U64(0xBF5CD546, 0x78EEF0B6), U64(0xD262D45A, 0x78A0635D), /* ~= 10^-197 */ U64(0xEF340A98, 0x172AACE4), U64(0x86FB8971, 0x16C87C34), /* ~= 10^-196 */ U64(0x9580869F, 0x0E7AAC0E), U64(0xD45D35E6, 0xAE3D4DA0), /* ~= 10^-195 */ U64(0xBAE0A846, 0xD2195712), U64(0x89748360, 0x59CCA109), /* ~= 10^-194 */ U64(0xE998D258, 0x869FACD7), U64(0x2BD1A438, 0x703FC94B), /* ~= 10^-193 */ U64(0x91FF8377, 0x5423CC06), U64(0x7B6306A3, 0x4627DDCF), /* ~= 10^-192 */ U64(0xB67F6455, 0x292CBF08), U64(0x1A3BC84C, 0x17B1D542), /* ~= 10^-191 */ U64(0xE41F3D6A, 0x7377EECA), U64(0x20CABA5F, 0x1D9E4A93), /* ~= 10^-190 */ U64(0x8E938662, 0x882AF53E), U64(0x547EB47B, 0x7282EE9C), /* ~= 10^-189 */ U64(0xB23867FB, 0x2A35B28D), U64(0xE99E619A, 0x4F23AA43), /* ~= 10^-188 */ U64(0xDEC681F9, 0xF4C31F31), U64(0x6405FA00, 0xE2EC94D4), /* ~= 10^-187 */ U64(0x8B3C113C, 0x38F9F37E), U64(0xDE83BC40, 0x8DD3DD04), /* ~= 10^-186 */ U64(0xAE0B158B, 0x4738705E), U64(0x9624AB50, 0xB148D445), /* ~= 10^-185 */ U64(0xD98DDAEE, 0x19068C76), U64(0x3BADD624, 0xDD9B0957), /* ~= 10^-184 */ U64(0x87F8A8D4, 0xCFA417C9), U64(0xE54CA5D7, 0x0A80E5D6), /* ~= 10^-183 */ U64(0xA9F6D30A, 0x038D1DBC), U64(0x5E9FCF4C, 0xCD211F4C), /* ~= 10^-182 */ U64(0xD47487CC, 0x8470652B), U64(0x7647C320, 0x0069671F), /* ~= 10^-181 */ U64(0x84C8D4DF, 0xD2C63F3B), U64(0x29ECD9F4, 0x0041E073), /* ~= 10^-180 */ U64(0xA5FB0A17, 0xC777CF09), U64(0xF4681071, 0x00525890), /* ~= 10^-179 */ U64(0xCF79CC9D, 0xB955C2CC), U64(0x7182148D, 0x4066EEB4), /* ~= 10^-178 */ U64(0x81AC1FE2, 0x93D599BF), U64(0xC6F14CD8, 0x48405530), /* ~= 10^-177 */ U64(0xA21727DB, 0x38CB002F), U64(0xB8ADA00E, 0x5A506A7C), /* ~= 10^-176 */ U64(0xCA9CF1D2, 0x06FDC03B), U64(0xA6D90811, 0xF0E4851C), /* ~= 10^-175 */ U64(0xFD442E46, 0x88BD304A), U64(0x908F4A16, 0x6D1DA663), /* ~= 10^-174 */ U64(0x9E4A9CEC, 0x15763E2E), U64(0x9A598E4E, 0x043287FE), /* ~= 10^-173 */ U64(0xC5DD4427, 0x1AD3CDBA), U64(0x40EFF1E1, 0x853F29FD), /* ~= 10^-172 */ U64(0xF7549530, 0xE188C128), U64(0xD12BEE59, 0xE68EF47C), /* ~= 10^-171 */ U64(0x9A94DD3E, 0x8CF578B9), U64(0x82BB74F8, 0x301958CE), /* ~= 10^-170 */ U64(0xC13A148E, 0x3032D6E7), U64(0xE36A5236, 0x3C1FAF01), /* ~= 10^-169 */ U64(0xF18899B1, 0xBC3F8CA1), U64(0xDC44E6C3, 0xCB279AC1), /* ~= 10^-168 */ U64(0x96F5600F, 0x15A7B7E5), U64(0x29AB103A, 0x5EF8C0B9), /* ~= 10^-167 */ U64(0xBCB2B812, 0xDB11A5DE), U64(0x7415D448, 0xF6B6F0E7), /* ~= 10^-166 */ U64(0xEBDF6617, 0x91D60F56), U64(0x111B495B, 0x3464AD21), /* ~= 10^-165 */ U64(0x936B9FCE, 0xBB25C995), U64(0xCAB10DD9, 0x00BEEC34), /* ~= 10^-164 */ U64(0xB84687C2, 0x69EF3BFB), U64(0x3D5D514F, 0x40EEA742), /* ~= 10^-163 */ U64(0xE65829B3, 0x046B0AFA), U64(0x0CB4A5A3, 0x112A5112), /* ~= 10^-162 */ U64(0x8FF71A0F, 0xE2C2E6DC), U64(0x47F0E785, 0xEABA72AB), /* ~= 10^-161 */ U64(0xB3F4E093, 0xDB73A093), U64(0x59ED2167, 0x65690F56), /* ~= 10^-160 */ U64(0xE0F218B8, 0xD25088B8), U64(0x306869C1, 0x3EC3532C), /* ~= 10^-159 */ U64(0x8C974F73, 0x83725573), U64(0x1E414218, 0xC73A13FB), /* ~= 10^-158 */ U64(0xAFBD2350, 0x644EEACF), U64(0xE5D1929E, 0xF90898FA), /* ~= 10^-157 */ U64(0xDBAC6C24, 0x7D62A583), U64(0xDF45F746, 0xB74ABF39), /* ~= 10^-156 */ U64(0x894BC396, 0xCE5DA772), U64(0x6B8BBA8C, 0x328EB783), /* ~= 10^-155 */ U64(0xAB9EB47C, 0x81F5114F), U64(0x066EA92F, 0x3F326564), /* ~= 10^-154 */ U64(0xD686619B, 0xA27255A2), U64(0xC80A537B, 0x0EFEFEBD), /* ~= 10^-153 */ U64(0x8613FD01, 0x45877585), U64(0xBD06742C, 0xE95F5F36), /* ~= 10^-152 */ U64(0xA798FC41, 0x96E952E7), U64(0x2C481138, 0x23B73704), /* ~= 10^-151 */ U64(0xD17F3B51, 0xFCA3A7A0), U64(0xF75A1586, 0x2CA504C5), /* ~= 10^-150 */ U64(0x82EF8513, 0x3DE648C4), U64(0x9A984D73, 0xDBE722FB), /* ~= 10^-149 */ U64(0xA3AB6658, 0x0D5FDAF5), U64(0xC13E60D0, 0xD2E0EBBA), /* ~= 10^-148 */ U64(0xCC963FEE, 0x10B7D1B3), U64(0x318DF905, 0x079926A8), /* ~= 10^-147 */ U64(0xFFBBCFE9, 0x94E5C61F), U64(0xFDF17746, 0x497F7052), /* ~= 10^-146 */ U64(0x9FD561F1, 0xFD0F9BD3), U64(0xFEB6EA8B, 0xEDEFA633), /* ~= 10^-145 */ U64(0xC7CABA6E, 0x7C5382C8), U64(0xFE64A52E, 0xE96B8FC0), /* ~= 10^-144 */ U64(0xF9BD690A, 0x1B68637B), U64(0x3DFDCE7A, 0xA3C673B0), /* ~= 10^-143 */ U64(0x9C1661A6, 0x51213E2D), U64(0x06BEA10C, 0xA65C084E), /* ~= 10^-142 */ U64(0xC31BFA0F, 0xE5698DB8), U64(0x486E494F, 0xCFF30A62), /* ~= 10^-141 */ U64(0xF3E2F893, 0xDEC3F126), U64(0x5A89DBA3, 0xC3EFCCFA), /* ~= 10^-140 */ U64(0x986DDB5C, 0x6B3A76B7), U64(0xF8962946, 0x5A75E01C), /* ~= 10^-139 */ U64(0xBE895233, 0x86091465), U64(0xF6BBB397, 0xF1135823), /* ~= 10^-138 */ U64(0xEE2BA6C0, 0x678B597F), U64(0x746AA07D, 0xED582E2C), /* ~= 10^-137 */ U64(0x94DB4838, 0x40B717EF), U64(0xA8C2A44E, 0xB4571CDC), /* ~= 10^-136 */ U64(0xBA121A46, 0x50E4DDEB), U64(0x92F34D62, 0x616CE413), /* ~= 10^-135 */ U64(0xE896A0D7, 0xE51E1566), U64(0x77B020BA, 0xF9C81D17), /* ~= 10^-134 */ U64(0x915E2486, 0xEF32CD60), U64(0x0ACE1474, 0xDC1D122E), /* ~= 10^-133 */ U64(0xB5B5ADA8, 0xAAFF80B8), U64(0x0D819992, 0x132456BA), /* ~= 10^-132 */ U64(0xE3231912, 0xD5BF60E6), U64(0x10E1FFF6, 0x97ED6C69), /* ~= 10^-131 */ U64(0x8DF5EFAB, 0xC5979C8F), U64(0xCA8D3FFA, 0x1EF463C1), /* ~= 10^-130 */ U64(0xB1736B96, 0xB6FD83B3), U64(0xBD308FF8, 0xA6B17CB2), /* ~= 10^-129 */ U64(0xDDD0467C, 0x64BCE4A0), U64(0xAC7CB3F6, 0xD05DDBDE), /* ~= 10^-128 */ U64(0x8AA22C0D, 0xBEF60EE4), U64(0x6BCDF07A, 0x423AA96B), /* ~= 10^-127 */ U64(0xAD4AB711, 0x2EB3929D), U64(0x86C16C98, 0xD2C953C6), /* ~= 10^-126 */ U64(0xD89D64D5, 0x7A607744), U64(0xE871C7BF, 0x077BA8B7), /* ~= 10^-125 */ U64(0x87625F05, 0x6C7C4A8B), U64(0x11471CD7, 0x64AD4972), /* ~= 10^-124 */ U64(0xA93AF6C6, 0xC79B5D2D), U64(0xD598E40D, 0x3DD89BCF), /* ~= 10^-123 */ U64(0xD389B478, 0x79823479), U64(0x4AFF1D10, 0x8D4EC2C3), /* ~= 10^-122 */ U64(0x843610CB, 0x4BF160CB), U64(0xCEDF722A, 0x585139BA), /* ~= 10^-121 */ U64(0xA54394FE, 0x1EEDB8FE), U64(0xC2974EB4, 0xEE658828), /* ~= 10^-120 */ U64(0xCE947A3D, 0xA6A9273E), U64(0x733D2262, 0x29FEEA32), /* ~= 10^-119 */ U64(0x811CCC66, 0x8829B887), U64(0x0806357D, 0x5A3F525F), /* ~= 10^-118 */ U64(0xA163FF80, 0x2A3426A8), U64(0xCA07C2DC, 0xB0CF26F7), /* ~= 10^-117 */ U64(0xC9BCFF60, 0x34C13052), U64(0xFC89B393, 0xDD02F0B5), /* ~= 10^-116 */ U64(0xFC2C3F38, 0x41F17C67), U64(0xBBAC2078, 0xD443ACE2), /* ~= 10^-115 */ U64(0x9D9BA783, 0x2936EDC0), U64(0xD54B944B, 0x84AA4C0D), /* ~= 10^-114 */ U64(0xC5029163, 0xF384A931), U64(0x0A9E795E, 0x65D4DF11), /* ~= 10^-113 */ U64(0xF64335BC, 0xF065D37D), U64(0x4D4617B5, 0xFF4A16D5), /* ~= 10^-112 */ U64(0x99EA0196, 0x163FA42E), U64(0x504BCED1, 0xBF8E4E45), /* ~= 10^-111 */ U64(0xC06481FB, 0x9BCF8D39), U64(0xE45EC286, 0x2F71E1D6), /* ~= 10^-110 */ U64(0xF07DA27A, 0x82C37088), U64(0x5D767327, 0xBB4E5A4C), /* ~= 10^-109 */ U64(0x964E858C, 0x91BA2655), U64(0x3A6A07F8, 0xD510F86F), /* ~= 10^-108 */ U64(0xBBE226EF, 0xB628AFEA), U64(0x890489F7, 0x0A55368B), /* ~= 10^-107 */ U64(0xEADAB0AB, 0xA3B2DBE5), U64(0x2B45AC74, 0xCCEA842E), /* ~= 10^-106 */ U64(0x92C8AE6B, 0x464FC96F), U64(0x3B0B8BC9, 0x0012929D), /* ~= 10^-105 */ U64(0xB77ADA06, 0x17E3BBCB), U64(0x09CE6EBB, 0x40173744), /* ~= 10^-104 */ U64(0xE5599087, 0x9DDCAABD), U64(0xCC420A6A, 0x101D0515), /* ~= 10^-103 */ U64(0x8F57FA54, 0xC2A9EAB6), U64(0x9FA94682, 0x4A12232D), /* ~= 10^-102 */ U64(0xB32DF8E9, 0xF3546564), U64(0x47939822, 0xDC96ABF9), /* ~= 10^-101 */ U64(0xDFF97724, 0x70297EBD), U64(0x59787E2B, 0x93BC56F7), /* ~= 10^-100 */ U64(0x8BFBEA76, 0xC619EF36), U64(0x57EB4EDB, 0x3C55B65A), /* ~= 10^-99 */ U64(0xAEFAE514, 0x77A06B03), U64(0xEDE62292, 0x0B6B23F1), /* ~= 10^-98 */ U64(0xDAB99E59, 0x958885C4), U64(0xE95FAB36, 0x8E45ECED), /* ~= 10^-97 */ U64(0x88B402F7, 0xFD75539B), U64(0x11DBCB02, 0x18EBB414), /* ~= 10^-96 */ U64(0xAAE103B5, 0xFCD2A881), U64(0xD652BDC2, 0x9F26A119), /* ~= 10^-95 */ U64(0xD59944A3, 0x7C0752A2), U64(0x4BE76D33, 0x46F0495F), /* ~= 10^-94 */ U64(0x857FCAE6, 0x2D8493A5), U64(0x6F70A440, 0x0C562DDB), /* ~= 10^-93 */ U64(0xA6DFBD9F, 0xB8E5B88E), U64(0xCB4CCD50, 0x0F6BB952), /* ~= 10^-92 */ U64(0xD097AD07, 0xA71F26B2), U64(0x7E2000A4, 0x1346A7A7), /* ~= 10^-91 */ U64(0x825ECC24, 0xC873782F), U64(0x8ED40066, 0x8C0C28C8), /* ~= 10^-90 */ U64(0xA2F67F2D, 0xFA90563B), U64(0x72890080, 0x2F0F32FA), /* ~= 10^-89 */ U64(0xCBB41EF9, 0x79346BCA), U64(0x4F2B40A0, 0x3AD2FFB9), /* ~= 10^-88 */ U64(0xFEA126B7, 0xD78186BC), U64(0xE2F610C8, 0x4987BFA8), /* ~= 10^-87 */ U64(0x9F24B832, 0xE6B0F436), U64(0x0DD9CA7D, 0x2DF4D7C9), /* ~= 10^-86 */ U64(0xC6EDE63F, 0xA05D3143), U64(0x91503D1C, 0x79720DBB), /* ~= 10^-85 */ U64(0xF8A95FCF, 0x88747D94), U64(0x75A44C63, 0x97CE912A), /* ~= 10^-84 */ U64(0x9B69DBE1, 0xB548CE7C), U64(0xC986AFBE, 0x3EE11ABA), /* ~= 10^-83 */ U64(0xC24452DA, 0x229B021B), U64(0xFBE85BAD, 0xCE996168), /* ~= 10^-82 */ U64(0xF2D56790, 0xAB41C2A2), U64(0xFAE27299, 0x423FB9C3), /* ~= 10^-81 */ U64(0x97C560BA, 0x6B0919A5), U64(0xDCCD879F, 0xC967D41A), /* ~= 10^-80 */ U64(0xBDB6B8E9, 0x05CB600F), U64(0x5400E987, 0xBBC1C920), /* ~= 10^-79 */ U64(0xED246723, 0x473E3813), U64(0x290123E9, 0xAAB23B68), /* ~= 10^-78 */ U64(0x9436C076, 0x0C86E30B), U64(0xF9A0B672, 0x0AAF6521), /* ~= 10^-77 */ U64(0xB9447093, 0x8FA89BCE), U64(0xF808E40E, 0x8D5B3E69), /* ~= 10^-76 */ U64(0xE7958CB8, 0x7392C2C2), U64(0xB60B1D12, 0x30B20E04), /* ~= 10^-75 */ U64(0x90BD77F3, 0x483BB9B9), U64(0xB1C6F22B, 0x5E6F48C2), /* ~= 10^-74 */ U64(0xB4ECD5F0, 0x1A4AA828), U64(0x1E38AEB6, 0x360B1AF3), /* ~= 10^-73 */ U64(0xE2280B6C, 0x20DD5232), U64(0x25C6DA63, 0xC38DE1B0), /* ~= 10^-72 */ U64(0x8D590723, 0x948A535F), U64(0x579C487E, 0x5A38AD0E), /* ~= 10^-71 */ U64(0xB0AF48EC, 0x79ACE837), U64(0x2D835A9D, 0xF0C6D851), /* ~= 10^-70 */ U64(0xDCDB1B27, 0x98182244), U64(0xF8E43145, 0x6CF88E65), /* ~= 10^-69 */ U64(0x8A08F0F8, 0xBF0F156B), U64(0x1B8E9ECB, 0x641B58FF), /* ~= 10^-68 */ U64(0xAC8B2D36, 0xEED2DAC5), U64(0xE272467E, 0x3D222F3F), /* ~= 10^-67 */ U64(0xD7ADF884, 0xAA879177), U64(0x5B0ED81D, 0xCC6ABB0F), /* ~= 10^-66 */ U64(0x86CCBB52, 0xEA94BAEA), U64(0x98E94712, 0x9FC2B4E9), /* ~= 10^-65 */ U64(0xA87FEA27, 0xA539E9A5), U64(0x3F2398D7, 0x47B36224), /* ~= 10^-64 */ U64(0xD29FE4B1, 0x8E88640E), U64(0x8EEC7F0D, 0x19A03AAD), /* ~= 10^-63 */ U64(0x83A3EEEE, 0xF9153E89), U64(0x1953CF68, 0x300424AC), /* ~= 10^-62 */ U64(0xA48CEAAA, 0xB75A8E2B), U64(0x5FA8C342, 0x3C052DD7), /* ~= 10^-61 */ U64(0xCDB02555, 0x653131B6), U64(0x3792F412, 0xCB06794D), /* ~= 10^-60 */ U64(0x808E1755, 0x5F3EBF11), U64(0xE2BBD88B, 0xBEE40BD0), /* ~= 10^-59 */ U64(0xA0B19D2A, 0xB70E6ED6), U64(0x5B6ACEAE, 0xAE9D0EC4), /* ~= 10^-58 */ U64(0xC8DE0475, 0x64D20A8B), U64(0xF245825A, 0x5A445275), /* ~= 10^-57 */ U64(0xFB158592, 0xBE068D2E), U64(0xEED6E2F0, 0xF0D56712), /* ~= 10^-56 */ U64(0x9CED737B, 0xB6C4183D), U64(0x55464DD6, 0x9685606B), /* ~= 10^-55 */ U64(0xC428D05A, 0xA4751E4C), U64(0xAA97E14C, 0x3C26B886), /* ~= 10^-54 */ U64(0xF5330471, 0x4D9265DF), U64(0xD53DD99F, 0x4B3066A8), /* ~= 10^-53 */ U64(0x993FE2C6, 0xD07B7FAB), U64(0xE546A803, 0x8EFE4029), /* ~= 10^-52 */ U64(0xBF8FDB78, 0x849A5F96), U64(0xDE985204, 0x72BDD033), /* ~= 10^-51 */ U64(0xEF73D256, 0xA5C0F77C), U64(0x963E6685, 0x8F6D4440), /* ~= 10^-50 */ U64(0x95A86376, 0x27989AAD), U64(0xDDE70013, 0x79A44AA8), /* ~= 10^-49 */ U64(0xBB127C53, 0xB17EC159), U64(0x5560C018, 0x580D5D52), /* ~= 10^-48 */ U64(0xE9D71B68, 0x9DDE71AF), U64(0xAAB8F01E, 0x6E10B4A6), /* ~= 10^-47 */ U64(0x92267121, 0x62AB070D), U64(0xCAB39613, 0x04CA70E8), /* ~= 10^-46 */ U64(0xB6B00D69, 0xBB55C8D1), U64(0x3D607B97, 0xC5FD0D22), /* ~= 10^-45 */ U64(0xE45C10C4, 0x2A2B3B05), U64(0x8CB89A7D, 0xB77C506A), /* ~= 10^-44 */ U64(0x8EB98A7A, 0x9A5B04E3), U64(0x77F3608E, 0x92ADB242), /* ~= 10^-43 */ U64(0xB267ED19, 0x40F1C61C), U64(0x55F038B2, 0x37591ED3), /* ~= 10^-42 */ U64(0xDF01E85F, 0x912E37A3), U64(0x6B6C46DE, 0xC52F6688), /* ~= 10^-41 */ U64(0x8B61313B, 0xBABCE2C6), U64(0x2323AC4B, 0x3B3DA015), /* ~= 10^-40 */ U64(0xAE397D8A, 0xA96C1B77), U64(0xABEC975E, 0x0A0D081A), /* ~= 10^-39 */ U64(0xD9C7DCED, 0x53C72255), U64(0x96E7BD35, 0x8C904A21), /* ~= 10^-38 */ U64(0x881CEA14, 0x545C7575), U64(0x7E50D641, 0x77DA2E54), /* ~= 10^-37 */ U64(0xAA242499, 0x697392D2), U64(0xDDE50BD1, 0xD5D0B9E9), /* ~= 10^-36 */ U64(0xD4AD2DBF, 0xC3D07787), U64(0x955E4EC6, 0x4B44E864), /* ~= 10^-35 */ U64(0x84EC3C97, 0xDA624AB4), U64(0xBD5AF13B, 0xEF0B113E), /* ~= 10^-34 */ U64(0xA6274BBD, 0xD0FADD61), U64(0xECB1AD8A, 0xEACDD58E), /* ~= 10^-33 */ U64(0xCFB11EAD, 0x453994BA), U64(0x67DE18ED, 0xA5814AF2), /* ~= 10^-32 */ U64(0x81CEB32C, 0x4B43FCF4), U64(0x80EACF94, 0x8770CED7), /* ~= 10^-31 */ U64(0xA2425FF7, 0x5E14FC31), U64(0xA1258379, 0xA94D028D), /* ~= 10^-30 */ U64(0xCAD2F7F5, 0x359A3B3E), U64(0x096EE458, 0x13A04330), /* ~= 10^-29 */ U64(0xFD87B5F2, 0x8300CA0D), U64(0x8BCA9D6E, 0x188853FC), /* ~= 10^-28 */ U64(0x9E74D1B7, 0x91E07E48), U64(0x775EA264, 0xCF55347D), /* ~= 10^-27 */ U64(0xC6120625, 0x76589DDA), U64(0x95364AFE, 0x032A819D), /* ~= 10^-26 */ U64(0xF79687AE, 0xD3EEC551), U64(0x3A83DDBD, 0x83F52204), /* ~= 10^-25 */ U64(0x9ABE14CD, 0x44753B52), U64(0xC4926A96, 0x72793542), /* ~= 10^-24 */ U64(0xC16D9A00, 0x95928A27), U64(0x75B7053C, 0x0F178293), /* ~= 10^-23 */ U64(0xF1C90080, 0xBAF72CB1), U64(0x5324C68B, 0x12DD6338), /* ~= 10^-22 */ U64(0x971DA050, 0x74DA7BEE), U64(0xD3F6FC16, 0xEBCA5E03), /* ~= 10^-21 */ U64(0xBCE50864, 0x92111AEA), U64(0x88F4BB1C, 0xA6BCF584), /* ~= 10^-20 */ U64(0xEC1E4A7D, 0xB69561A5), U64(0x2B31E9E3, 0xD06C32E5), /* ~= 10^-19 */ U64(0x9392EE8E, 0x921D5D07), U64(0x3AFF322E, 0x62439FCF), /* ~= 10^-18 */ U64(0xB877AA32, 0x36A4B449), U64(0x09BEFEB9, 0xFAD487C2), /* ~= 10^-17 */ U64(0xE69594BE, 0xC44DE15B), U64(0x4C2EBE68, 0x7989A9B3), /* ~= 10^-16 */ U64(0x901D7CF7, 0x3AB0ACD9), U64(0x0F9D3701, 0x4BF60A10), /* ~= 10^-15 */ U64(0xB424DC35, 0x095CD80F), U64(0x538484C1, 0x9EF38C94), /* ~= 10^-14 */ U64(0xE12E1342, 0x4BB40E13), U64(0x2865A5F2, 0x06B06FB9), /* ~= 10^-13 */ U64(0x8CBCCC09, 0x6F5088CB), U64(0xF93F87B7, 0x442E45D3), /* ~= 10^-12 */ U64(0xAFEBFF0B, 0xCB24AAFE), U64(0xF78F69A5, 0x1539D748), /* ~= 10^-11 */ U64(0xDBE6FECE, 0xBDEDD5BE), U64(0xB573440E, 0x5A884D1B), /* ~= 10^-10 */ U64(0x89705F41, 0x36B4A597), U64(0x31680A88, 0xF8953030), /* ~= 10^-9 */ U64(0xABCC7711, 0x8461CEFC), U64(0xFDC20D2B, 0x36BA7C3D), /* ~= 10^-8 */ U64(0xD6BF94D5, 0xE57A42BC), U64(0x3D329076, 0x04691B4C), /* ~= 10^-7 */ U64(0x8637BD05, 0xAF6C69B5), U64(0xA63F9A49, 0xC2C1B10F), /* ~= 10^-6 */ U64(0xA7C5AC47, 0x1B478423), U64(0x0FCF80DC, 0x33721D53), /* ~= 10^-5 */ U64(0xD1B71758, 0xE219652B), U64(0xD3C36113, 0x404EA4A8), /* ~= 10^-4 */ U64(0x83126E97, 0x8D4FDF3B), U64(0x645A1CAC, 0x083126E9), /* ~= 10^-3 */ U64(0xA3D70A3D, 0x70A3D70A), U64(0x3D70A3D7, 0x0A3D70A3), /* ~= 10^-2 */ U64(0xCCCCCCCC, 0xCCCCCCCC), U64(0xCCCCCCCC, 0xCCCCCCCC), /* ~= 10^-1 */ U64(0x80000000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^0 */ U64(0xA0000000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^1 */ U64(0xC8000000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^2 */ U64(0xFA000000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^3 */ U64(0x9C400000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^4 */ U64(0xC3500000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^5 */ U64(0xF4240000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^6 */ U64(0x98968000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^7 */ U64(0xBEBC2000, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^8 */ U64(0xEE6B2800, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^9 */ U64(0x9502F900, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^10 */ U64(0xBA43B740, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^11 */ U64(0xE8D4A510, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^12 */ U64(0x9184E72A, 0x00000000), U64(0x00000000, 0x00000000), /* == 10^13 */ U64(0xB5E620F4, 0x80000000), U64(0x00000000, 0x00000000), /* == 10^14 */ U64(0xE35FA931, 0xA0000000), U64(0x00000000, 0x00000000), /* == 10^15 */ U64(0x8E1BC9BF, 0x04000000), U64(0x00000000, 0x00000000), /* == 10^16 */ U64(0xB1A2BC2E, 0xC5000000), U64(0x00000000, 0x00000000), /* == 10^17 */ U64(0xDE0B6B3A, 0x76400000), U64(0x00000000, 0x00000000), /* == 10^18 */ U64(0x8AC72304, 0x89E80000), U64(0x00000000, 0x00000000), /* == 10^19 */ U64(0xAD78EBC5, 0xAC620000), U64(0x00000000, 0x00000000), /* == 10^20 */ U64(0xD8D726B7, 0x177A8000), U64(0x00000000, 0x00000000), /* == 10^21 */ U64(0x87867832, 0x6EAC9000), U64(0x00000000, 0x00000000), /* == 10^22 */ U64(0xA968163F, 0x0A57B400), U64(0x00000000, 0x00000000), /* == 10^23 */ U64(0xD3C21BCE, 0xCCEDA100), U64(0x00000000, 0x00000000), /* == 10^24 */ U64(0x84595161, 0x401484A0), U64(0x00000000, 0x00000000), /* == 10^25 */ U64(0xA56FA5B9, 0x9019A5C8), U64(0x00000000, 0x00000000), /* == 10^26 */ U64(0xCECB8F27, 0xF4200F3A), U64(0x00000000, 0x00000000), /* == 10^27 */ U64(0x813F3978, 0xF8940984), U64(0x40000000, 0x00000000), /* == 10^28 */ U64(0xA18F07D7, 0x36B90BE5), U64(0x50000000, 0x00000000), /* == 10^29 */ U64(0xC9F2C9CD, 0x04674EDE), U64(0xA4000000, 0x00000000), /* == 10^30 */ U64(0xFC6F7C40, 0x45812296), U64(0x4D000000, 0x00000000), /* == 10^31 */ U64(0x9DC5ADA8, 0x2B70B59D), U64(0xF0200000, 0x00000000), /* == 10^32 */ U64(0xC5371912, 0x364CE305), U64(0x6C280000, 0x00000000), /* == 10^33 */ U64(0xF684DF56, 0xC3E01BC6), U64(0xC7320000, 0x00000000), /* == 10^34 */ U64(0x9A130B96, 0x3A6C115C), U64(0x3C7F4000, 0x00000000), /* == 10^35 */ U64(0xC097CE7B, 0xC90715B3), U64(0x4B9F1000, 0x00000000), /* == 10^36 */ U64(0xF0BDC21A, 0xBB48DB20), U64(0x1E86D400, 0x00000000), /* == 10^37 */ U64(0x96769950, 0xB50D88F4), U64(0x13144480, 0x00000000), /* == 10^38 */ U64(0xBC143FA4, 0xE250EB31), U64(0x17D955A0, 0x00000000), /* == 10^39 */ U64(0xEB194F8E, 0x1AE525FD), U64(0x5DCFAB08, 0x00000000), /* == 10^40 */ U64(0x92EFD1B8, 0xD0CF37BE), U64(0x5AA1CAE5, 0x00000000), /* == 10^41 */ U64(0xB7ABC627, 0x050305AD), U64(0xF14A3D9E, 0x40000000), /* == 10^42 */ U64(0xE596B7B0, 0xC643C719), U64(0x6D9CCD05, 0xD0000000), /* == 10^43 */ U64(0x8F7E32CE, 0x7BEA5C6F), U64(0xE4820023, 0xA2000000), /* == 10^44 */ U64(0xB35DBF82, 0x1AE4F38B), U64(0xDDA2802C, 0x8A800000), /* == 10^45 */ U64(0xE0352F62, 0xA19E306E), U64(0xD50B2037, 0xAD200000), /* == 10^46 */ U64(0x8C213D9D, 0xA502DE45), U64(0x4526F422, 0xCC340000), /* == 10^47 */ U64(0xAF298D05, 0x0E4395D6), U64(0x9670B12B, 0x7F410000), /* == 10^48 */ U64(0xDAF3F046, 0x51D47B4C), U64(0x3C0CDD76, 0x5F114000), /* == 10^49 */ U64(0x88D8762B, 0xF324CD0F), U64(0xA5880A69, 0xFB6AC800), /* == 10^50 */ U64(0xAB0E93B6, 0xEFEE0053), U64(0x8EEA0D04, 0x7A457A00), /* == 10^51 */ U64(0xD5D238A4, 0xABE98068), U64(0x72A49045, 0x98D6D880), /* == 10^52 */ U64(0x85A36366, 0xEB71F041), U64(0x47A6DA2B, 0x7F864750), /* == 10^53 */ U64(0xA70C3C40, 0xA64E6C51), U64(0x999090B6, 0x5F67D924), /* == 10^54 */ U64(0xD0CF4B50, 0xCFE20765), U64(0xFFF4B4E3, 0xF741CF6D), /* == 10^55 */ U64(0x82818F12, 0x81ED449F), U64(0xBFF8F10E, 0x7A8921A4), /* ~= 10^56 */ U64(0xA321F2D7, 0x226895C7), U64(0xAFF72D52, 0x192B6A0D), /* ~= 10^57 */ U64(0xCBEA6F8C, 0xEB02BB39), U64(0x9BF4F8A6, 0x9F764490), /* ~= 10^58 */ U64(0xFEE50B70, 0x25C36A08), U64(0x02F236D0, 0x4753D5B4), /* ~= 10^59 */ U64(0x9F4F2726, 0x179A2245), U64(0x01D76242, 0x2C946590), /* ~= 10^60 */ U64(0xC722F0EF, 0x9D80AAD6), U64(0x424D3AD2, 0xB7B97EF5), /* ~= 10^61 */ U64(0xF8EBAD2B, 0x84E0D58B), U64(0xD2E08987, 0x65A7DEB2), /* ~= 10^62 */ U64(0x9B934C3B, 0x330C8577), U64(0x63CC55F4, 0x9F88EB2F), /* ~= 10^63 */ U64(0xC2781F49, 0xFFCFA6D5), U64(0x3CBF6B71, 0xC76B25FB), /* ~= 10^64 */ U64(0xF316271C, 0x7FC3908A), U64(0x8BEF464E, 0x3945EF7A), /* ~= 10^65 */ U64(0x97EDD871, 0xCFDA3A56), U64(0x97758BF0, 0xE3CBB5AC), /* ~= 10^66 */ U64(0xBDE94E8E, 0x43D0C8EC), U64(0x3D52EEED, 0x1CBEA317), /* ~= 10^67 */ U64(0xED63A231, 0xD4C4FB27), U64(0x4CA7AAA8, 0x63EE4BDD), /* ~= 10^68 */ U64(0x945E455F, 0x24FB1CF8), U64(0x8FE8CAA9, 0x3E74EF6A), /* ~= 10^69 */ U64(0xB975D6B6, 0xEE39E436), U64(0xB3E2FD53, 0x8E122B44), /* ~= 10^70 */ U64(0xE7D34C64, 0xA9C85D44), U64(0x60DBBCA8, 0x7196B616), /* ~= 10^71 */ U64(0x90E40FBE, 0xEA1D3A4A), U64(0xBC8955E9, 0x46FE31CD), /* ~= 10^72 */ U64(0xB51D13AE, 0xA4A488DD), U64(0x6BABAB63, 0x98BDBE41), /* ~= 10^73 */ U64(0xE264589A, 0x4DCDAB14), U64(0xC696963C, 0x7EED2DD1), /* ~= 10^74 */ U64(0x8D7EB760, 0x70A08AEC), U64(0xFC1E1DE5, 0xCF543CA2), /* ~= 10^75 */ U64(0xB0DE6538, 0x8CC8ADA8), U64(0x3B25A55F, 0x43294BCB), /* ~= 10^76 */ U64(0xDD15FE86, 0xAFFAD912), U64(0x49EF0EB7, 0x13F39EBE), /* ~= 10^77 */ U64(0x8A2DBF14, 0x2DFCC7AB), U64(0x6E356932, 0x6C784337), /* ~= 10^78 */ U64(0xACB92ED9, 0x397BF996), U64(0x49C2C37F, 0x07965404), /* ~= 10^79 */ U64(0xD7E77A8F, 0x87DAF7FB), U64(0xDC33745E, 0xC97BE906), /* ~= 10^80 */ U64(0x86F0AC99, 0xB4E8DAFD), U64(0x69A028BB, 0x3DED71A3), /* ~= 10^81 */ U64(0xA8ACD7C0, 0x222311BC), U64(0xC40832EA, 0x0D68CE0C), /* ~= 10^82 */ U64(0xD2D80DB0, 0x2AABD62B), U64(0xF50A3FA4, 0x90C30190), /* ~= 10^83 */ U64(0x83C7088E, 0x1AAB65DB), U64(0x792667C6, 0xDA79E0FA), /* ~= 10^84 */ U64(0xA4B8CAB1, 0xA1563F52), U64(0x577001B8, 0x91185938), /* ~= 10^85 */ U64(0xCDE6FD5E, 0x09ABCF26), U64(0xED4C0226, 0xB55E6F86), /* ~= 10^86 */ U64(0x80B05E5A, 0xC60B6178), U64(0x544F8158, 0x315B05B4), /* ~= 10^87 */ U64(0xA0DC75F1, 0x778E39D6), U64(0x696361AE, 0x3DB1C721), /* ~= 10^88 */ U64(0xC913936D, 0xD571C84C), U64(0x03BC3A19, 0xCD1E38E9), /* ~= 10^89 */ U64(0xFB587849, 0x4ACE3A5F), U64(0x04AB48A0, 0x4065C723), /* ~= 10^90 */ U64(0x9D174B2D, 0xCEC0E47B), U64(0x62EB0D64, 0x283F9C76), /* ~= 10^91 */ U64(0xC45D1DF9, 0x42711D9A), U64(0x3BA5D0BD, 0x324F8394), /* ~= 10^92 */ U64(0xF5746577, 0x930D6500), U64(0xCA8F44EC, 0x7EE36479), /* ~= 10^93 */ U64(0x9968BF6A, 0xBBE85F20), U64(0x7E998B13, 0xCF4E1ECB), /* ~= 10^94 */ U64(0xBFC2EF45, 0x6AE276E8), U64(0x9E3FEDD8, 0xC321A67E), /* ~= 10^95 */ U64(0xEFB3AB16, 0xC59B14A2), U64(0xC5CFE94E, 0xF3EA101E), /* ~= 10^96 */ U64(0x95D04AEE, 0x3B80ECE5), U64(0xBBA1F1D1, 0x58724A12), /* ~= 10^97 */ U64(0xBB445DA9, 0xCA61281F), U64(0x2A8A6E45, 0xAE8EDC97), /* ~= 10^98 */ U64(0xEA157514, 0x3CF97226), U64(0xF52D09D7, 0x1A3293BD), /* ~= 10^99 */ U64(0x924D692C, 0xA61BE758), U64(0x593C2626, 0x705F9C56), /* ~= 10^100 */ U64(0xB6E0C377, 0xCFA2E12E), U64(0x6F8B2FB0, 0x0C77836C), /* ~= 10^101 */ U64(0xE498F455, 0xC38B997A), U64(0x0B6DFB9C, 0x0F956447), /* ~= 10^102 */ U64(0x8EDF98B5, 0x9A373FEC), U64(0x4724BD41, 0x89BD5EAC), /* ~= 10^103 */ U64(0xB2977EE3, 0x00C50FE7), U64(0x58EDEC91, 0xEC2CB657), /* ~= 10^104 */ U64(0xDF3D5E9B, 0xC0F653E1), U64(0x2F2967B6, 0x6737E3ED), /* ~= 10^105 */ U64(0x8B865B21, 0x5899F46C), U64(0xBD79E0D2, 0x0082EE74), /* ~= 10^106 */ U64(0xAE67F1E9, 0xAEC07187), U64(0xECD85906, 0x80A3AA11), /* ~= 10^107 */ U64(0xDA01EE64, 0x1A708DE9), U64(0xE80E6F48, 0x20CC9495), /* ~= 10^108 */ U64(0x884134FE, 0x908658B2), U64(0x3109058D, 0x147FDCDD), /* ~= 10^109 */ U64(0xAA51823E, 0x34A7EEDE), U64(0xBD4B46F0, 0x599FD415), /* ~= 10^110 */ U64(0xD4E5E2CD, 0xC1D1EA96), U64(0x6C9E18AC, 0x7007C91A), /* ~= 10^111 */ U64(0x850FADC0, 0x9923329E), U64(0x03E2CF6B, 0xC604DDB0), /* ~= 10^112 */ U64(0xA6539930, 0xBF6BFF45), U64(0x84DB8346, 0xB786151C), /* ~= 10^113 */ U64(0xCFE87F7C, 0xEF46FF16), U64(0xE6126418, 0x65679A63), /* ~= 10^114 */ U64(0x81F14FAE, 0x158C5F6E), U64(0x4FCB7E8F, 0x3F60C07E), /* ~= 10^115 */ U64(0xA26DA399, 0x9AEF7749), U64(0xE3BE5E33, 0x0F38F09D), /* ~= 10^116 */ U64(0xCB090C80, 0x01AB551C), U64(0x5CADF5BF, 0xD3072CC5), /* ~= 10^117 */ U64(0xFDCB4FA0, 0x02162A63), U64(0x73D9732F, 0xC7C8F7F6), /* ~= 10^118 */ U64(0x9E9F11C4, 0x014DDA7E), U64(0x2867E7FD, 0xDCDD9AFA), /* ~= 10^119 */ U64(0xC646D635, 0x01A1511D), U64(0xB281E1FD, 0x541501B8), /* ~= 10^120 */ U64(0xF7D88BC2, 0x4209A565), U64(0x1F225A7C, 0xA91A4226), /* ~= 10^121 */ U64(0x9AE75759, 0x6946075F), U64(0x3375788D, 0xE9B06958), /* ~= 10^122 */ U64(0xC1A12D2F, 0xC3978937), U64(0x0052D6B1, 0x641C83AE), /* ~= 10^123 */ U64(0xF209787B, 0xB47D6B84), U64(0xC0678C5D, 0xBD23A49A), /* ~= 10^124 */ U64(0x9745EB4D, 0x50CE6332), U64(0xF840B7BA, 0x963646E0), /* ~= 10^125 */ U64(0xBD176620, 0xA501FBFF), U64(0xB650E5A9, 0x3BC3D898), /* ~= 10^126 */ U64(0xEC5D3FA8, 0xCE427AFF), U64(0xA3E51F13, 0x8AB4CEBE), /* ~= 10^127 */ U64(0x93BA47C9, 0x80E98CDF), U64(0xC66F336C, 0x36B10137), /* ~= 10^128 */ U64(0xB8A8D9BB, 0xE123F017), U64(0xB80B0047, 0x445D4184), /* ~= 10^129 */ U64(0xE6D3102A, 0xD96CEC1D), U64(0xA60DC059, 0x157491E5), /* ~= 10^130 */ U64(0x9043EA1A, 0xC7E41392), U64(0x87C89837, 0xAD68DB2F), /* ~= 10^131 */ U64(0xB454E4A1, 0x79DD1877), U64(0x29BABE45, 0x98C311FB), /* ~= 10^132 */ U64(0xE16A1DC9, 0xD8545E94), U64(0xF4296DD6, 0xFEF3D67A), /* ~= 10^133 */ U64(0x8CE2529E, 0x2734BB1D), U64(0x1899E4A6, 0x5F58660C), /* ~= 10^134 */ U64(0xB01AE745, 0xB101E9E4), U64(0x5EC05DCF, 0xF72E7F8F), /* ~= 10^135 */ U64(0xDC21A117, 0x1D42645D), U64(0x76707543, 0xF4FA1F73), /* ~= 10^136 */ U64(0x899504AE, 0x72497EBA), U64(0x6A06494A, 0x791C53A8), /* ~= 10^137 */ U64(0xABFA45DA, 0x0EDBDE69), U64(0x0487DB9D, 0x17636892), /* ~= 10^138 */ U64(0xD6F8D750, 0x9292D603), U64(0x45A9D284, 0x5D3C42B6), /* ~= 10^139 */ U64(0x865B8692, 0x5B9BC5C2), U64(0x0B8A2392, 0xBA45A9B2), /* ~= 10^140 */ U64(0xA7F26836, 0xF282B732), U64(0x8E6CAC77, 0x68D7141E), /* ~= 10^141 */ U64(0xD1EF0244, 0xAF2364FF), U64(0x3207D795, 0x430CD926), /* ~= 10^142 */ U64(0x8335616A, 0xED761F1F), U64(0x7F44E6BD, 0x49E807B8), /* ~= 10^143 */ U64(0xA402B9C5, 0xA8D3A6E7), U64(0x5F16206C, 0x9C6209A6), /* ~= 10^144 */ U64(0xCD036837, 0x130890A1), U64(0x36DBA887, 0xC37A8C0F), /* ~= 10^145 */ U64(0x80222122, 0x6BE55A64), U64(0xC2494954, 0xDA2C9789), /* ~= 10^146 */ U64(0xA02AA96B, 0x06DEB0FD), U64(0xF2DB9BAA, 0x10B7BD6C), /* ~= 10^147 */ U64(0xC83553C5, 0xC8965D3D), U64(0x6F928294, 0x94E5ACC7), /* ~= 10^148 */ U64(0xFA42A8B7, 0x3ABBF48C), U64(0xCB772339, 0xBA1F17F9), /* ~= 10^149 */ U64(0x9C69A972, 0x84B578D7), U64(0xFF2A7604, 0x14536EFB), /* ~= 10^150 */ U64(0xC38413CF, 0x25E2D70D), U64(0xFEF51385, 0x19684ABA), /* ~= 10^151 */ U64(0xF46518C2, 0xEF5B8CD1), U64(0x7EB25866, 0x5FC25D69), /* ~= 10^152 */ U64(0x98BF2F79, 0xD5993802), U64(0xEF2F773F, 0xFBD97A61), /* ~= 10^153 */ U64(0xBEEEFB58, 0x4AFF8603), U64(0xAAFB550F, 0xFACFD8FA), /* ~= 10^154 */ U64(0xEEAABA2E, 0x5DBF6784), U64(0x95BA2A53, 0xF983CF38), /* ~= 10^155 */ U64(0x952AB45C, 0xFA97A0B2), U64(0xDD945A74, 0x7BF26183), /* ~= 10^156 */ U64(0xBA756174, 0x393D88DF), U64(0x94F97111, 0x9AEEF9E4), /* ~= 10^157 */ U64(0xE912B9D1, 0x478CEB17), U64(0x7A37CD56, 0x01AAB85D), /* ~= 10^158 */ U64(0x91ABB422, 0xCCB812EE), U64(0xAC62E055, 0xC10AB33A), /* ~= 10^159 */ U64(0xB616A12B, 0x7FE617AA), U64(0x577B986B, 0x314D6009), /* ~= 10^160 */ U64(0xE39C4976, 0x5FDF9D94), U64(0xED5A7E85, 0xFDA0B80B), /* ~= 10^161 */ U64(0x8E41ADE9, 0xFBEBC27D), U64(0x14588F13, 0xBE847307), /* ~= 10^162 */ U64(0xB1D21964, 0x7AE6B31C), U64(0x596EB2D8, 0xAE258FC8), /* ~= 10^163 */ U64(0xDE469FBD, 0x99A05FE3), U64(0x6FCA5F8E, 0xD9AEF3BB), /* ~= 10^164 */ U64(0x8AEC23D6, 0x80043BEE), U64(0x25DE7BB9, 0x480D5854), /* ~= 10^165 */ U64(0xADA72CCC, 0x20054AE9), U64(0xAF561AA7, 0x9A10AE6A), /* ~= 10^166 */ U64(0xD910F7FF, 0x28069DA4), U64(0x1B2BA151, 0x8094DA04), /* ~= 10^167 */ U64(0x87AA9AFF, 0x79042286), U64(0x90FB44D2, 0xF05D0842), /* ~= 10^168 */ U64(0xA99541BF, 0x57452B28), U64(0x353A1607, 0xAC744A53), /* ~= 10^169 */ U64(0xD3FA922F, 0x2D1675F2), U64(0x42889B89, 0x97915CE8), /* ~= 10^170 */ U64(0x847C9B5D, 0x7C2E09B7), U64(0x69956135, 0xFEBADA11), /* ~= 10^171 */ U64(0xA59BC234, 0xDB398C25), U64(0x43FAB983, 0x7E699095), /* ~= 10^172 */ U64(0xCF02B2C2, 0x1207EF2E), U64(0x94F967E4, 0x5E03F4BB), /* ~= 10^173 */ U64(0x8161AFB9, 0x4B44F57D), U64(0x1D1BE0EE, 0xBAC278F5), /* ~= 10^174 */ U64(0xA1BA1BA7, 0x9E1632DC), U64(0x6462D92A, 0x69731732), /* ~= 10^175 */ U64(0xCA28A291, 0x859BBF93), U64(0x7D7B8F75, 0x03CFDCFE), /* ~= 10^176 */ U64(0xFCB2CB35, 0xE702AF78), U64(0x5CDA7352, 0x44C3D43E), /* ~= 10^177 */ U64(0x9DEFBF01, 0xB061ADAB), U64(0x3A088813, 0x6AFA64A7), /* ~= 10^178 */ U64(0xC56BAEC2, 0x1C7A1916), U64(0x088AAA18, 0x45B8FDD0), /* ~= 10^179 */ U64(0xF6C69A72, 0xA3989F5B), U64(0x8AAD549E, 0x57273D45), /* ~= 10^180 */ U64(0x9A3C2087, 0xA63F6399), U64(0x36AC54E2, 0xF678864B), /* ~= 10^181 */ U64(0xC0CB28A9, 0x8FCF3C7F), U64(0x84576A1B, 0xB416A7DD), /* ~= 10^182 */ U64(0xF0FDF2D3, 0xF3C30B9F), U64(0x656D44A2, 0xA11C51D5), /* ~= 10^183 */ U64(0x969EB7C4, 0x7859E743), U64(0x9F644AE5, 0xA4B1B325), /* ~= 10^184 */ U64(0xBC4665B5, 0x96706114), U64(0x873D5D9F, 0x0DDE1FEE), /* ~= 10^185 */ U64(0xEB57FF22, 0xFC0C7959), U64(0xA90CB506, 0xD155A7EA), /* ~= 10^186 */ U64(0x9316FF75, 0xDD87CBD8), U64(0x09A7F124, 0x42D588F2), /* ~= 10^187 */ U64(0xB7DCBF53, 0x54E9BECE), U64(0x0C11ED6D, 0x538AEB2F), /* ~= 10^188 */ U64(0xE5D3EF28, 0x2A242E81), U64(0x8F1668C8, 0xA86DA5FA), /* ~= 10^189 */ U64(0x8FA47579, 0x1A569D10), U64(0xF96E017D, 0x694487BC), /* ~= 10^190 */ U64(0xB38D92D7, 0x60EC4455), U64(0x37C981DC, 0xC395A9AC), /* ~= 10^191 */ U64(0xE070F78D, 0x3927556A), U64(0x85BBE253, 0xF47B1417), /* ~= 10^192 */ U64(0x8C469AB8, 0x43B89562), U64(0x93956D74, 0x78CCEC8E), /* ~= 10^193 */ U64(0xAF584166, 0x54A6BABB), U64(0x387AC8D1, 0x970027B2), /* ~= 10^194 */ U64(0xDB2E51BF, 0xE9D0696A), U64(0x06997B05, 0xFCC0319E), /* ~= 10^195 */ U64(0x88FCF317, 0xF22241E2), U64(0x441FECE3, 0xBDF81F03), /* ~= 10^196 */ U64(0xAB3C2FDD, 0xEEAAD25A), U64(0xD527E81C, 0xAD7626C3), /* ~= 10^197 */ U64(0xD60B3BD5, 0x6A5586F1), U64(0x8A71E223, 0xD8D3B074), /* ~= 10^198 */ U64(0x85C70565, 0x62757456), U64(0xF6872D56, 0x67844E49), /* ~= 10^199 */ U64(0xA738C6BE, 0xBB12D16C), U64(0xB428F8AC, 0x016561DB), /* ~= 10^200 */ U64(0xD106F86E, 0x69D785C7), U64(0xE13336D7, 0x01BEBA52), /* ~= 10^201 */ U64(0x82A45B45, 0x0226B39C), U64(0xECC00246, 0x61173473), /* ~= 10^202 */ U64(0xA34D7216, 0x42B06084), U64(0x27F002D7, 0xF95D0190), /* ~= 10^203 */ U64(0xCC20CE9B, 0xD35C78A5), U64(0x31EC038D, 0xF7B441F4), /* ~= 10^204 */ U64(0xFF290242, 0xC83396CE), U64(0x7E670471, 0x75A15271), /* ~= 10^205 */ U64(0x9F79A169, 0xBD203E41), U64(0x0F0062C6, 0xE984D386), /* ~= 10^206 */ U64(0xC75809C4, 0x2C684DD1), U64(0x52C07B78, 0xA3E60868), /* ~= 10^207 */ U64(0xF92E0C35, 0x37826145), U64(0xA7709A56, 0xCCDF8A82), /* ~= 10^208 */ U64(0x9BBCC7A1, 0x42B17CCB), U64(0x88A66076, 0x400BB691), /* ~= 10^209 */ U64(0xC2ABF989, 0x935DDBFE), U64(0x6ACFF893, 0xD00EA435), /* ~= 10^210 */ U64(0xF356F7EB, 0xF83552FE), U64(0x0583F6B8, 0xC4124D43), /* ~= 10^211 */ U64(0x98165AF3, 0x7B2153DE), U64(0xC3727A33, 0x7A8B704A), /* ~= 10^212 */ U64(0xBE1BF1B0, 0x59E9A8D6), U64(0x744F18C0, 0x592E4C5C), /* ~= 10^213 */ U64(0xEDA2EE1C, 0x7064130C), U64(0x1162DEF0, 0x6F79DF73), /* ~= 10^214 */ U64(0x9485D4D1, 0xC63E8BE7), U64(0x8ADDCB56, 0x45AC2BA8), /* ~= 10^215 */ U64(0xB9A74A06, 0x37CE2EE1), U64(0x6D953E2B, 0xD7173692), /* ~= 10^216 */ U64(0xE8111C87, 0xC5C1BA99), U64(0xC8FA8DB6, 0xCCDD0437), /* ~= 10^217 */ U64(0x910AB1D4, 0xDB9914A0), U64(0x1D9C9892, 0x400A22A2), /* ~= 10^218 */ U64(0xB54D5E4A, 0x127F59C8), U64(0x2503BEB6, 0xD00CAB4B), /* ~= 10^219 */ U64(0xE2A0B5DC, 0x971F303A), U64(0x2E44AE64, 0x840FD61D), /* ~= 10^220 */ U64(0x8DA471A9, 0xDE737E24), U64(0x5CEAECFE, 0xD289E5D2), /* ~= 10^221 */ U64(0xB10D8E14, 0x56105DAD), U64(0x7425A83E, 0x872C5F47), /* ~= 10^222 */ U64(0xDD50F199, 0x6B947518), U64(0xD12F124E, 0x28F77719), /* ~= 10^223 */ U64(0x8A5296FF, 0xE33CC92F), U64(0x82BD6B70, 0xD99AAA6F), /* ~= 10^224 */ U64(0xACE73CBF, 0xDC0BFB7B), U64(0x636CC64D, 0x1001550B), /* ~= 10^225 */ U64(0xD8210BEF, 0xD30EFA5A), U64(0x3C47F7E0, 0x5401AA4E), /* ~= 10^226 */ U64(0x8714A775, 0xE3E95C78), U64(0x65ACFAEC, 0x34810A71), /* ~= 10^227 */ U64(0xA8D9D153, 0x5CE3B396), U64(0x7F1839A7, 0x41A14D0D), /* ~= 10^228 */ U64(0xD31045A8, 0x341CA07C), U64(0x1EDE4811, 0x1209A050), /* ~= 10^229 */ U64(0x83EA2B89, 0x2091E44D), U64(0x934AED0A, 0xAB460432), /* ~= 10^230 */ U64(0xA4E4B66B, 0x68B65D60), U64(0xF81DA84D, 0x5617853F), /* ~= 10^231 */ U64(0xCE1DE406, 0x42E3F4B9), U64(0x36251260, 0xAB9D668E), /* ~= 10^232 */ U64(0x80D2AE83, 0xE9CE78F3), U64(0xC1D72B7C, 0x6B426019), /* ~= 10^233 */ U64(0xA1075A24, 0xE4421730), U64(0xB24CF65B, 0x8612F81F), /* ~= 10^234 */ U64(0xC94930AE, 0x1D529CFC), U64(0xDEE033F2, 0x6797B627), /* ~= 10^235 */ U64(0xFB9B7CD9, 0xA4A7443C), U64(0x169840EF, 0x017DA3B1), /* ~= 10^236 */ U64(0x9D412E08, 0x06E88AA5), U64(0x8E1F2895, 0x60EE864E), /* ~= 10^237 */ U64(0xC491798A, 0x08A2AD4E), U64(0xF1A6F2BA, 0xB92A27E2), /* ~= 10^238 */ U64(0xF5B5D7EC, 0x8ACB58A2), U64(0xAE10AF69, 0x6774B1DB), /* ~= 10^239 */ U64(0x9991A6F3, 0xD6BF1765), U64(0xACCA6DA1, 0xE0A8EF29), /* ~= 10^240 */ U64(0xBFF610B0, 0xCC6EDD3F), U64(0x17FD090A, 0x58D32AF3), /* ~= 10^241 */ U64(0xEFF394DC, 0xFF8A948E), U64(0xDDFC4B4C, 0xEF07F5B0), /* ~= 10^242 */ U64(0x95F83D0A, 0x1FB69CD9), U64(0x4ABDAF10, 0x1564F98E), /* ~= 10^243 */ U64(0xBB764C4C, 0xA7A4440F), U64(0x9D6D1AD4, 0x1ABE37F1), /* ~= 10^244 */ U64(0xEA53DF5F, 0xD18D5513), U64(0x84C86189, 0x216DC5ED), /* ~= 10^245 */ U64(0x92746B9B, 0xE2F8552C), U64(0x32FD3CF5, 0xB4E49BB4), /* ~= 10^246 */ U64(0xB7118682, 0xDBB66A77), U64(0x3FBC8C33, 0x221DC2A1), /* ~= 10^247 */ U64(0xE4D5E823, 0x92A40515), U64(0x0FABAF3F, 0xEAA5334A), /* ~= 10^248 */ U64(0x8F05B116, 0x3BA6832D), U64(0x29CB4D87, 0xF2A7400E), /* ~= 10^249 */ U64(0xB2C71D5B, 0xCA9023F8), U64(0x743E20E9, 0xEF511012), /* ~= 10^250 */ U64(0xDF78E4B2, 0xBD342CF6), U64(0x914DA924, 0x6B255416), /* ~= 10^251 */ U64(0x8BAB8EEF, 0xB6409C1A), U64(0x1AD089B6, 0xC2F7548E), /* ~= 10^252 */ U64(0xAE9672AB, 0xA3D0C320), U64(0xA184AC24, 0x73B529B1), /* ~= 10^253 */ U64(0xDA3C0F56, 0x8CC4F3E8), U64(0xC9E5D72D, 0x90A2741E), /* ~= 10^254 */ U64(0x88658996, 0x17FB1871), U64(0x7E2FA67C, 0x7A658892), /* ~= 10^255 */ U64(0xAA7EEBFB, 0x9DF9DE8D), U64(0xDDBB901B, 0x98FEEAB7), /* ~= 10^256 */ U64(0xD51EA6FA, 0x85785631), U64(0x552A7422, 0x7F3EA565), /* ~= 10^257 */ U64(0x8533285C, 0x936B35DE), U64(0xD53A8895, 0x8F87275F), /* ~= 10^258 */ U64(0xA67FF273, 0xB8460356), U64(0x8A892ABA, 0xF368F137), /* ~= 10^259 */ U64(0xD01FEF10, 0xA657842C), U64(0x2D2B7569, 0xB0432D85), /* ~= 10^260 */ U64(0x8213F56A, 0x67F6B29B), U64(0x9C3B2962, 0x0E29FC73), /* ~= 10^261 */ U64(0xA298F2C5, 0x01F45F42), U64(0x8349F3BA, 0x91B47B8F), /* ~= 10^262 */ U64(0xCB3F2F76, 0x42717713), U64(0x241C70A9, 0x36219A73), /* ~= 10^263 */ U64(0xFE0EFB53, 0xD30DD4D7), U64(0xED238CD3, 0x83AA0110), /* ~= 10^264 */ U64(0x9EC95D14, 0x63E8A506), U64(0xF4363804, 0x324A40AA), /* ~= 10^265 */ U64(0xC67BB459, 0x7CE2CE48), U64(0xB143C605, 0x3EDCD0D5), /* ~= 10^266 */ U64(0xF81AA16F, 0xDC1B81DA), U64(0xDD94B786, 0x8E94050A), /* ~= 10^267 */ U64(0x9B10A4E5, 0xE9913128), U64(0xCA7CF2B4, 0x191C8326), /* ~= 10^268 */ U64(0xC1D4CE1F, 0x63F57D72), U64(0xFD1C2F61, 0x1F63A3F0), /* ~= 10^269 */ U64(0xF24A01A7, 0x3CF2DCCF), U64(0xBC633B39, 0x673C8CEC), /* ~= 10^270 */ U64(0x976E4108, 0x8617CA01), U64(0xD5BE0503, 0xE085D813), /* ~= 10^271 */ U64(0xBD49D14A, 0xA79DBC82), U64(0x4B2D8644, 0xD8A74E18), /* ~= 10^272 */ U64(0xEC9C459D, 0x51852BA2), U64(0xDDF8E7D6, 0x0ED1219E), /* ~= 10^273 */ U64(0x93E1AB82, 0x52F33B45), U64(0xCABB90E5, 0xC942B503), /* ~= 10^274 */ U64(0xB8DA1662, 0xE7B00A17), U64(0x3D6A751F, 0x3B936243), /* ~= 10^275 */ U64(0xE7109BFB, 0xA19C0C9D), U64(0x0CC51267, 0x0A783AD4), /* ~= 10^276 */ U64(0x906A617D, 0x450187E2), U64(0x27FB2B80, 0x668B24C5), /* ~= 10^277 */ U64(0xB484F9DC, 0x9641E9DA), U64(0xB1F9F660, 0x802DEDF6), /* ~= 10^278 */ U64(0xE1A63853, 0xBBD26451), U64(0x5E7873F8, 0xA0396973), /* ~= 10^279 */ U64(0x8D07E334, 0x55637EB2), U64(0xDB0B487B, 0x6423E1E8), /* ~= 10^280 */ U64(0xB049DC01, 0x6ABC5E5F), U64(0x91CE1A9A, 0x3D2CDA62), /* ~= 10^281 */ U64(0xDC5C5301, 0xC56B75F7), U64(0x7641A140, 0xCC7810FB), /* ~= 10^282 */ U64(0x89B9B3E1, 0x1B6329BA), U64(0xA9E904C8, 0x7FCB0A9D), /* ~= 10^283 */ U64(0xAC2820D9, 0x623BF429), U64(0x546345FA, 0x9FBDCD44), /* ~= 10^284 */ U64(0xD732290F, 0xBACAF133), U64(0xA97C1779, 0x47AD4095), /* ~= 10^285 */ U64(0x867F59A9, 0xD4BED6C0), U64(0x49ED8EAB, 0xCCCC485D), /* ~= 10^286 */ U64(0xA81F3014, 0x49EE8C70), U64(0x5C68F256, 0xBFFF5A74), /* ~= 10^287 */ U64(0xD226FC19, 0x5C6A2F8C), U64(0x73832EEC, 0x6FFF3111), /* ~= 10^288 */ U64(0x83585D8F, 0xD9C25DB7), U64(0xC831FD53, 0xC5FF7EAB), /* ~= 10^289 */ U64(0xA42E74F3, 0xD032F525), U64(0xBA3E7CA8, 0xB77F5E55), /* ~= 10^290 */ U64(0xCD3A1230, 0xC43FB26F), U64(0x28CE1BD2, 0xE55F35EB), /* ~= 10^291 */ U64(0x80444B5E, 0x7AA7CF85), U64(0x7980D163, 0xCF5B81B3), /* ~= 10^292 */ U64(0xA0555E36, 0x1951C366), U64(0xD7E105BC, 0xC332621F), /* ~= 10^293 */ U64(0xC86AB5C3, 0x9FA63440), U64(0x8DD9472B, 0xF3FEFAA7), /* ~= 10^294 */ U64(0xFA856334, 0x878FC150), U64(0xB14F98F6, 0xF0FEB951), /* ~= 10^295 */ U64(0x9C935E00, 0xD4B9D8D2), U64(0x6ED1BF9A, 0x569F33D3), /* ~= 10^296 */ U64(0xC3B83581, 0x09E84F07), U64(0x0A862F80, 0xEC4700C8), /* ~= 10^297 */ U64(0xF4A642E1, 0x4C6262C8), U64(0xCD27BB61, 0x2758C0FA), /* ~= 10^298 */ U64(0x98E7E9CC, 0xCFBD7DBD), U64(0x8038D51C, 0xB897789C), /* ~= 10^299 */ U64(0xBF21E440, 0x03ACDD2C), U64(0xE0470A63, 0xE6BD56C3), /* ~= 10^300 */ U64(0xEEEA5D50, 0x04981478), U64(0x1858CCFC, 0xE06CAC74), /* ~= 10^301 */ U64(0x95527A52, 0x02DF0CCB), U64(0x0F37801E, 0x0C43EBC8), /* ~= 10^302 */ U64(0xBAA718E6, 0x8396CFFD), U64(0xD3056025, 0x8F54E6BA), /* ~= 10^303 */ U64(0xE950DF20, 0x247C83FD), U64(0x47C6B82E, 0xF32A2069), /* ~= 10^304 */ U64(0x91D28B74, 0x16CDD27E), U64(0x4CDC331D, 0x57FA5441), /* ~= 10^305 */ U64(0xB6472E51, 0x1C81471D), U64(0xE0133FE4, 0xADF8E952), /* ~= 10^306 */ U64(0xE3D8F9E5, 0x63A198E5), U64(0x58180FDD, 0xD97723A6), /* ~= 10^307 */ U64(0x8E679C2F, 0x5E44FF8F), U64(0x570F09EA, 0xA7EA7648), /* ~= 10^308 */ U64(0xB201833B, 0x35D63F73), U64(0x2CD2CC65, 0x51E513DA), /* ~= 10^309 */ U64(0xDE81E40A, 0x034BCF4F), U64(0xF8077F7E, 0xA65E58D1), /* ~= 10^310 */ U64(0x8B112E86, 0x420F6191), U64(0xFB04AFAF, 0x27FAF782), /* ~= 10^311 */ U64(0xADD57A27, 0xD29339F6), U64(0x79C5DB9A, 0xF1F9B563), /* ~= 10^312 */ U64(0xD94AD8B1, 0xC7380874), U64(0x18375281, 0xAE7822BC), /* ~= 10^313 */ U64(0x87CEC76F, 0x1C830548), U64(0x8F229391, 0x0D0B15B5), /* ~= 10^314 */ U64(0xA9C2794A, 0xE3A3C69A), U64(0xB2EB3875, 0x504DDB22), /* ~= 10^315 */ U64(0xD433179D, 0x9C8CB841), U64(0x5FA60692, 0xA46151EB), /* ~= 10^316 */ U64(0x849FEEC2, 0x81D7F328), U64(0xDBC7C41B, 0xA6BCD333), /* ~= 10^317 */ U64(0xA5C7EA73, 0x224DEFF3), U64(0x12B9B522, 0x906C0800), /* ~= 10^318 */ U64(0xCF39E50F, 0xEAE16BEF), U64(0xD768226B, 0x34870A00), /* ~= 10^319 */ U64(0x81842F29, 0xF2CCE375), U64(0xE6A11583, 0x00D46640), /* ~= 10^320 */ U64(0xA1E53AF4, 0x6F801C53), U64(0x60495AE3, 0xC1097FD0), /* ~= 10^321 */ U64(0xCA5E89B1, 0x8B602368), U64(0x385BB19C, 0xB14BDFC4), /* ~= 10^322 */ U64(0xFCF62C1D, 0xEE382C42), U64(0x46729E03, 0xDD9ED7B5), /* ~= 10^323 */ U64(0x9E19DB92, 0xB4E31BA9), U64(0x6C07A2C2, 0x6A8346D1) /* ~= 10^324 */ }; /** Get the cached pow10 value from pow10_sig_table. @param exp10 The exponent of pow(10, e). This value must in range POW10_SIG_TABLE_MIN_EXP to POW10_SIG_TABLE_MAX_EXP. @param hi The highest 64 bits of pow(10, e). @param lo The lower 64 bits after `hi`. */ static_inline void pow10_table_get_sig(i32 exp10, u64 *hi, u64 *lo) { i32 idx = exp10 - (POW10_SIG_TABLE_MIN_EXP); *hi = pow10_sig_table[idx * 2]; *lo = pow10_sig_table[idx * 2 + 1]; } /** Get the exponent (base 2) for highest 64 bits significand in pow10_sig_table. */ static_inline void pow10_table_get_exp(i32 exp10, i32 *exp2) { /* e2 = floor(log2(pow(10, e))) - 64 + 1 */ /* = floor(e * log2(10) - 63) */ *exp2 = (exp10 * 217706 - 4128768) >> 16; } #endif /*============================================================================== * JSON Character Matcher *============================================================================*/ /** Character type */ typedef u8 char_type; /** Whitespace character: ' ', '\\t', '\\n', '\\r'. */ static const char_type CHAR_TYPE_SPACE = 1 << 0; /** Number character: '-', [0-9]. */ static const char_type CHAR_TYPE_NUMBER = 1 << 1; /** JSON Escaped character: '"', '\', [0x00-0x1F]. */ static const char_type CHAR_TYPE_ESC_ASCII = 1 << 2; /** Non-ASCII character: [0x80-0xFF]. */ static const char_type CHAR_TYPE_NON_ASCII = 1 << 3; /** JSON container character: '{', '['. */ static const char_type CHAR_TYPE_CONTAINER = 1 << 4; /** Comment character: '/'. */ static const char_type CHAR_TYPE_COMMENT = 1 << 5; /** Line end character: '\\n', '\\r', '\0'. */ static const char_type CHAR_TYPE_LINE_END = 1 << 6; /** Hexadecimal numeric character: [0-9a-fA-F]. */ static const char_type CHAR_TYPE_HEX = 1 << 7; /** Character type table (generate with misc/make_tables.c) */ static const char_type char_table[256] = { 0x44, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x45, 0x04, 0x04, 0x45, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x20, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; /** Match a character with specified type. */ static_inline bool char_is_type(u8 c, char_type type) { return (char_table[c] & type) != 0; } /** Match a whitespace: ' ', '\\t', '\\n', '\\r'. */ static_inline bool char_is_space(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_SPACE); } /** Match a whitespace or comment: ' ', '\\t', '\\n', '\\r', '/'. */ static_inline bool char_is_space_or_comment(u8 c) { return char_is_type(c, (char_type)(CHAR_TYPE_SPACE | CHAR_TYPE_COMMENT)); } /** Match a JSON number: '-', [0-9]. */ static_inline bool char_is_number(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_NUMBER); } /** Match a JSON container: '{', '['. */ static_inline bool char_is_container(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_CONTAINER); } /** Match a stop character in ASCII string: '"', '\', [0x00-0x1F,0x80-0xFF]. */ static_inline bool char_is_ascii_stop(u8 c) { return char_is_type(c, (char_type)(CHAR_TYPE_ESC_ASCII | CHAR_TYPE_NON_ASCII)); } /** Match a line end character: '\\n', '\\r', '\0'. */ static_inline bool char_is_line_end(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_LINE_END); } /** Match a hexadecimal numeric character: [0-9a-fA-F]. */ static_inline bool char_is_hex(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_HEX); } /*============================================================================== * Digit Character Matcher *============================================================================*/ /** Digit type */ typedef u8 digi_type; /** Digit: '0'. */ static const digi_type DIGI_TYPE_ZERO = 1 << 0; /** Digit: [1-9]. */ static const digi_type DIGI_TYPE_NONZERO = 1 << 1; /** Plus sign (positive): '+'. */ static const digi_type DIGI_TYPE_POS = 1 << 2; /** Minus sign (negative): '-'. */ static const digi_type DIGI_TYPE_NEG = 1 << 3; /** Decimal point: '.' */ static const digi_type DIGI_TYPE_DOT = 1 << 4; /** Exponent sign: 'e, 'E'. */ static const digi_type DIGI_TYPE_EXP = 1 << 5; /** Digit type table (generate with misc/make_tables.c) */ static const digi_type digi_table[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x10, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /** Match a character with specified type. */ static_inline bool digi_is_type(u8 d, digi_type type) { return (digi_table[d] & type) != 0; } /** Match a sign: '+', '-' */ static_inline bool digi_is_sign(u8 d) { return digi_is_type(d, (digi_type)(DIGI_TYPE_POS | DIGI_TYPE_NEG)); } /** Match a none zero digit: [1-9] */ static_inline bool digi_is_nonzero(u8 d) { return digi_is_type(d, (digi_type)DIGI_TYPE_NONZERO); } /** Match a digit: [0-9] */ static_inline bool digi_is_digit(u8 d) { return digi_is_type(d, (digi_type)(DIGI_TYPE_ZERO | DIGI_TYPE_NONZERO)); } /** Match an exponent sign: 'e', 'E'. */ static_inline bool digi_is_exp(u8 d) { return digi_is_type(d, (digi_type)DIGI_TYPE_EXP); } /** Match a floating point indicator: '.', 'e', 'E'. */ static_inline bool digi_is_fp(u8 d) { return digi_is_type(d, (digi_type)(DIGI_TYPE_DOT | DIGI_TYPE_EXP)); } /** Match a digit or floating point indicator: [0-9], '.', 'e', 'E'. */ static_inline bool digi_is_digit_or_fp(u8 d) { return digi_is_type(d, (digi_type)(DIGI_TYPE_ZERO | DIGI_TYPE_NONZERO | DIGI_TYPE_DOT | DIGI_TYPE_EXP)); } #if !YYJSON_DISABLE_READER /*============================================================================== * Hex Character Reader * This function is used by JSON reader to read escaped characters. *============================================================================*/ /** This table is used to convert 4 hex character sequence to a number. A valid hex character [0-9A-Fa-f] will mapped to it's raw number [0x00, 0x0F], an invalid hex character will mapped to [0xF0]. (generate with misc/make_tables.c) */ static const u8 hex_conv_table[256] = { 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0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F0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0 }; /** Scans an escaped character sequence as a UTF-16 code unit (branchless). e.g. "\\u005C" should pass "005C" as `cur`. This requires the string has 4-byte zero padding. */ static_inline bool read_hex_u16(const u8 *cur, u16 *val) { u16 c0, c1, c2, c3, t0, t1; c0 = hex_conv_table[cur[0]]; c1 = hex_conv_table[cur[1]]; c2 = hex_conv_table[cur[2]]; c3 = hex_conv_table[cur[3]]; t0 = (u16)((c0 << 8) | c2); t1 = (u16)((c1 << 8) | c3); *val = (u16)((t0 << 4) | t1); return ((t0 | t1) & (u16)0xF0F0) == 0; } /*============================================================================== * JSON Reader Utils * These functions are used by JSON reader to read literals and comments. *============================================================================*/ /** Read 'true' literal, '*cur' should be 't'. */ static_inline bool read_true(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; u8 **end = ptr; if (likely(byte_match_4(cur, "true"))) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; *end = cur + 4; return true; } return false; } /** Read 'false' literal, '*cur' should be 'f'. */ static_inline bool read_false(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; u8 **end = ptr; if (likely(byte_match_4(cur + 1, "alse"))) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; *end = cur + 5; return true; } return false; } /** Read 'null' literal, '*cur' should be 'n'. */ static_inline bool read_null(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; u8 **end = ptr; if (likely(byte_match_4(cur, "null"))) { val->tag = YYJSON_TYPE_NULL; *end = cur + 4; return true; } return false; } /** Read 'Inf' or 'Infinity' literal (ignoring case). */ static_inline bool read_inf(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { u8 *hdr = *ptr - sign; u8 *cur = *ptr; u8 **end = ptr; if ((cur[0] == 'I' || cur[0] == 'i') && (cur[1] == 'N' || cur[1] == 'n') && (cur[2] == 'F' || cur[2] == 'f')) { if ((cur[3] == 'I' || cur[3] == 'i') && (cur[4] == 'N' || cur[4] == 'n') && (cur[5] == 'I' || cur[5] == 'i') && (cur[6] == 'T' || cur[6] == 't') && (cur[7] == 'Y' || cur[7] == 'y')) { cur += 8; } else { cur += 3; } *end = cur; if (false) { /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; *pre = cur; val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; val->uni.str = (const char *)hdr; } else { val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.u64 = f64_raw_get_inf(sign); } return true; } return false; } /** Read 'NaN' literal (ignoring case). */ static_inline bool read_nan(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { u8 *hdr = *ptr - sign; u8 *cur = *ptr; u8 **end = ptr; if ((cur[0] == 'N' || cur[0] == 'n') && (cur[1] == 'A' || cur[1] == 'a') && (cur[2] == 'N' || cur[2] == 'n')) { cur += 3; *end = cur; if (false) { /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; *pre = cur; val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; val->uni.str = (const char *)hdr; } else { val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.u64 = f64_raw_get_nan(sign); } return true; } return false; } /** Read 'Inf', 'Infinity' or 'NaN' literal (ignoring case). */ static_inline bool read_inf_or_nan(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { if (read_inf(sign, ptr, pre, val)) return true; if (read_nan(sign, ptr, pre, val)) return true; return false; } /** Read a JSON number as raw string. */ static_noinline bool read_number_raw(u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg) { #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) #define return_raw() do { \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; /* skip sign */ cur += (*cur == '-'); /* read first digit, check leading zero */ if (unlikely(!digi_is_digit(*cur))) { if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_inf_or_nan(*hdr == '-', &cur, pre, val)) return_raw(); } return_err(cur, "no digit after minus sign"); } /* read integral part */ if (*cur == '0') { cur++; if (unlikely(digi_is_digit(*cur))) { return_err(cur - 1, "number with leading zero is not allowed"); } if (!digi_is_fp(*cur)) return_raw(); } else { while (digi_is_digit(*cur)) cur++; if (!digi_is_fp(*cur)) return_raw(); } /* read fraction part */ if (*cur == '.') { cur++; if (!digi_is_digit(*cur++)) { return_err(cur, "no digit after decimal point"); } while (digi_is_digit(*cur)) cur++; } /* read exponent part */ if (digi_is_exp(*cur)) { cur += 1 + digi_is_sign(cur[1]); if (!digi_is_digit(*cur++)) { return_err(cur, "no digit after exponent sign"); } while (digi_is_digit(*cur)) cur++; } return_raw(); #undef return_err #undef return_raw } /** Skips spaces and comments as many as possible. It will return false in these cases: 1. No character is skipped. The 'end' pointer is set as input cursor. 2. A multiline comment is not closed. The 'end' pointer is set as the head of this comment block. */ static_noinline bool skip_spaces_and_comments(u8 **ptr) { u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; while (true) { if (byte_match_2(cur, "/*")) { hdr = cur; cur += 2; while (true) { if (byte_match_2(cur, "*/")) { cur += 2; break; } if (*cur == 0) { *end = hdr; return false; } cur++; } continue; } if (byte_match_2(cur, "//")) { cur += 2; while (!char_is_line_end(*cur)) cur++; continue; } if (char_is_space(*cur)) { cur += 1; while (char_is_space(*cur)) cur++; continue; } break; } *end = cur; return hdr != cur; } /** Check truncated string. Returns true if `cur` match `str` but is truncated. */ static_inline bool is_truncated_str(u8 *cur, u8 *end, const char *str, bool case_sensitive) { usize len = strlen(str); if (cur + len <= end || end <= cur) return false; if (case_sensitive) { return memcmp(cur, str, (usize)(end - cur)) == 0; } for (; cur < end; cur++, str++) { if ((*cur != (u8)*str) && (*cur != (u8)*str - 'a' + 'A')) { return false; } } return true; } /** Check truncated JSON on parsing errors. Returns true if the input is valid but truncated. */ static_noinline bool is_truncated_end(u8 *hdr, u8 *cur, u8 *end, yyjson_read_code code, yyjson_read_flag flg) { if (cur >= end) return true; if (code == YYJSON_READ_ERROR_LITERAL) { if (is_truncated_str(cur, end, "true", true) || is_truncated_str(cur, end, "false", true) || is_truncated_str(cur, end, "null", true)) { return true; } } if (code == YYJSON_READ_ERROR_UNEXPECTED_CHARACTER || code == YYJSON_READ_ERROR_INVALID_NUMBER || code == YYJSON_READ_ERROR_LITERAL) { if (has_read_flag(ALLOW_INF_AND_NAN)) { if (*cur == '-') cur++; if (is_truncated_str(cur, end, "infinity", false) || is_truncated_str(cur, end, "nan", false)) { return true; } } } if (code == YYJSON_READ_ERROR_UNEXPECTED_CONTENT) { if (has_read_flag(ALLOW_INF_AND_NAN)) { if (hdr + 3 <= cur && is_truncated_str(cur - 3, end, "infinity", false)) { return true; /* e.g. infin would be read as inf + in */ } } } if (code == YYJSON_READ_ERROR_INVALID_STRING) { usize len = (usize)(end - cur); /* unicode escape sequence */ if (*cur == '\\') { if (len == 1) return true; if (len <= 5) { if (*++cur != 'u') return false; for (++cur; cur < end; cur++) { if (!char_is_hex(*cur)) return false; } return true; } return false; } /* 2 to 4 bytes UTF-8, see `read_string()` for details. */ if (*cur & 0x80) { u8 c0 = cur[0], c1 = cur[1], c2 = cur[2]; if (len == 1) { /* 2 bytes UTF-8, truncated */ if ((c0 & 0xE0) == 0xC0 && (c0 & 0x1E) != 0x00) return true; /* 3 bytes UTF-8, truncated */ if ((c0 & 0xF0) == 0xE0) return true; /* 4 bytes UTF-8, truncated */ if ((c0 & 0xF8) == 0xF0 && (c0 & 0x07) <= 0x04) return true; } if (len == 2) { /* 3 bytes UTF-8, truncated */ if ((c0 & 0xF0) == 0xE0 && (c1 & 0xC0) == 0x80) { u8 pat = (u8)(((c0 & 0x0F) << 1) | ((c1 & 0x20) >> 5)); return 0x01 <= pat && pat != 0x1B; } /* 4 bytes UTF-8, truncated */ if ((c0 & 0xF8) == 0xF0 && (c1 & 0xC0) == 0x80) { u8 pat = (u8)(((c0 & 0x07) << 2) | ((c1 & 0x30) >> 4)); return 0x01 <= pat && pat <= 0x10; } } if (len == 3) { /* 4 bytes UTF-8, truncated */ if ((c0 & 0xF8) == 0xF0 && (c1 & 0xC0) == 0x80 && (c2 & 0xC0) == 0x80) { u8 pat = (u8)(((c0 & 0x07) << 2) | ((c1 & 0x30) >> 4)); return 0x01 <= pat && pat <= 0x10; } } } } return false; } #if YYJSON_HAS_IEEE_754 && !YYJSON_DISABLE_FAST_FP_CONV /* FP_READER */ /*============================================================================== * BigInt For Floating Point Number Reader * * The bigint algorithm is used by floating-point number reader to get correctly * rounded result for numbers with lots of digits. This part of code is rarely * used for common numbers. *============================================================================*/ /** Maximum exponent of exact pow10 */ #define U64_POW10_MAX_EXP 19 /** Table: [ 10^0, ..., 10^19 ] (generate with misc/make_tables.c) */ static const u64 u64_pow10_table[U64_POW10_MAX_EXP + 1] = { U64(0x00000000, 0x00000001), U64(0x00000000, 0x0000000A), U64(0x00000000, 0x00000064), U64(0x00000000, 0x000003E8), U64(0x00000000, 0x00002710), U64(0x00000000, 0x000186A0), U64(0x00000000, 0x000F4240), U64(0x00000000, 0x00989680), U64(0x00000000, 0x05F5E100), U64(0x00000000, 0x3B9ACA00), U64(0x00000002, 0x540BE400), U64(0x00000017, 0x4876E800), U64(0x000000E8, 0xD4A51000), U64(0x00000918, 0x4E72A000), U64(0x00005AF3, 0x107A4000), U64(0x00038D7E, 0xA4C68000), U64(0x002386F2, 0x6FC10000), U64(0x01634578, 0x5D8A0000), U64(0x0DE0B6B3, 0xA7640000), U64(0x8AC72304, 0x89E80000) }; /** Maximum numbers of chunks used by a bigint (58 is enough here). */ #define BIGINT_MAX_CHUNKS 64 /** Unsigned arbitrarily large integer */ typedef struct bigint { u32 used; /* used chunks count, should not be 0 */ u64 bits[BIGINT_MAX_CHUNKS]; /* chunks */ } bigint; /** Evaluate 'big += val'. @param big A big number (can be 0). @param val An unsigned integer (can be 0). */ static_inline void bigint_add_u64(bigint *big, u64 val) { u32 idx, max; u64 num = big->bits[0]; u64 add = num + val; big->bits[0] = add; if (likely((add >= num) || (add >= val))) return; for ((void)(idx = 1), max = big->used; idx < max; idx++) { if (likely(big->bits[idx] != U64_MAX)) { big->bits[idx] += 1; return; } big->bits[idx] = 0; } big->bits[big->used++] = 1; } /** Evaluate 'big *= val'. @param big A big number (can be 0). @param val An unsigned integer (cannot be 0). */ static_inline void bigint_mul_u64(bigint *big, u64 val) { u32 idx = 0, max = big->used; u64 hi, lo, carry = 0; for (; idx < max; idx++) { if (big->bits[idx]) break; } for (; idx < max; idx++) { u128_mul_add(big->bits[idx], val, carry, &hi, &lo); big->bits[idx] = lo; carry = hi; } if (carry) big->bits[big->used++] = carry; } /** Evaluate 'big *= 2^exp'. @param big A big number (can be 0). @param exp An exponent integer (can be 0). */ static_inline void bigint_mul_pow2(bigint *big, u32 exp) { u32 shft = exp % 64; u32 move = exp / 64; u32 idx = big->used; if (unlikely(shft == 0)) { for (; idx > 0; idx--) { big->bits[idx + move - 1] = big->bits[idx - 1]; } big->used += move; while (move) big->bits[--move] = 0; } else { big->bits[idx] = 0; for (; idx > 0; idx--) { u64 num = big->bits[idx] << shft; num |= big->bits[idx - 1] >> (64 - shft); big->bits[idx + move] = num; } big->bits[move] = big->bits[0] << shft; big->used += move + (big->bits[big->used + move] > 0); while (move) big->bits[--move] = 0; } } /** Evaluate 'big *= 10^exp'. @param big A big number (can be 0). @param exp An exponent integer (cannot be 0). */ static_inline void bigint_mul_pow10(bigint *big, i32 exp) { for (; exp >= U64_POW10_MAX_EXP; exp -= U64_POW10_MAX_EXP) { bigint_mul_u64(big, u64_pow10_table[U64_POW10_MAX_EXP]); } if (exp) { bigint_mul_u64(big, u64_pow10_table[exp]); } } /** Compare two bigint. @return -1 if 'a < b', +1 if 'a > b', 0 if 'a == b'. */ static_inline i32 bigint_cmp(bigint *a, bigint *b) { u32 idx = a->used; if (a->used < b->used) return -1; if (a->used > b->used) return +1; while (idx-- > 0) { u64 av = a->bits[idx]; u64 bv = b->bits[idx]; if (av < bv) return -1; if (av > bv) return +1; } return 0; } /** Evaluate 'big = val'. @param big A big number (can be 0). @param val An unsigned integer (can be 0). */ static_inline void bigint_set_u64(bigint *big, u64 val) { big->used = 1; big->bits[0] = val; } /** Set a bigint with floating point number string. */ static_noinline void bigint_set_buf(bigint *big, u64 sig, i32 *exp, u8 *sig_cut, u8 *sig_end, u8 *dot_pos) { if (unlikely(!sig_cut)) { /* no digit cut, set significant part only */ bigint_set_u64(big, sig); return; } else { /* some digits were cut, read them from 'sig_cut' to 'sig_end' */ u8 *hdr = sig_cut; u8 *cur = hdr; u32 len = 0; u64 val = 0; bool dig_big_cut = false; bool has_dot = (hdr < dot_pos) & (dot_pos < sig_end); u32 dig_len_total = U64_SAFE_DIG + (u32)(sig_end - hdr) - has_dot; sig -= (*sig_cut >= '5'); /* sig was rounded before */ if (dig_len_total > F64_MAX_DEC_DIG) { dig_big_cut = true; sig_end -= dig_len_total - (F64_MAX_DEC_DIG + 1); sig_end -= (dot_pos + 1 == sig_end); dig_len_total = (F64_MAX_DEC_DIG + 1); } *exp -= (i32)dig_len_total - U64_SAFE_DIG; big->used = 1; big->bits[0] = sig; while (cur < sig_end) { if (likely(cur != dot_pos)) { val = val * 10 + (u8)(*cur++ - '0'); len++; if (unlikely(cur == sig_end && dig_big_cut)) { /* The last digit must be non-zero, */ /* set it to '1' for correct rounding. */ val = val - (val % 10) + 1; } if (len == U64_SAFE_DIG || cur == sig_end) { bigint_mul_pow10(big, (i32)len); bigint_add_u64(big, val); val = 0; len = 0; } } else { cur++; } } } } /*============================================================================== * Diy Floating Point *============================================================================*/ /** "Do It Yourself Floating Point" struct. */ typedef struct diy_fp { u64 sig; /* significand */ i32 exp; /* exponent, base 2 */ i32 pad; /* padding, useless */ } diy_fp; /** Get cached rounded diy_fp with pow(10, e) The input value must in range [POW10_SIG_TABLE_MIN_EXP, POW10_SIG_TABLE_MAX_EXP]. */ static_inline diy_fp diy_fp_get_cached_pow10(i32 exp10) { diy_fp fp; u64 sig_ext; pow10_table_get_sig(exp10, &fp.sig, &sig_ext); pow10_table_get_exp(exp10, &fp.exp); fp.sig += (sig_ext >> 63); return fp; } /** Returns fp * fp2. */ static_inline diy_fp diy_fp_mul(diy_fp fp, diy_fp fp2) { u64 hi, lo; u128_mul(fp.sig, fp2.sig, &hi, &lo); fp.sig = hi + (lo >> 63); fp.exp += fp2.exp + 64; return fp; } /** Convert diy_fp to IEEE-754 raw value. */ static_inline u64 diy_fp_to_ieee_raw(diy_fp fp) { u64 sig = fp.sig; i32 exp = fp.exp; u32 lz_bits; if (unlikely(fp.sig == 0)) return 0; lz_bits = u64_lz_bits(sig); sig <<= lz_bits; sig >>= F64_BITS - F64_SIG_FULL_BITS; exp -= (i32)lz_bits; exp += F64_BITS - F64_SIG_FULL_BITS; exp += F64_SIG_BITS; if (unlikely(exp >= F64_MAX_BIN_EXP)) { /* overflow */ return F64_RAW_INF; } else if (likely(exp >= F64_MIN_BIN_EXP - 1)) { /* normal */ exp += F64_EXP_BIAS; return ((u64)exp << F64_SIG_BITS) | (sig & F64_SIG_MASK); } else if (likely(exp >= F64_MIN_BIN_EXP - F64_SIG_FULL_BITS)) { /* subnormal */ return sig >> (F64_MIN_BIN_EXP - exp - 1); } else { /* underflow */ return 0; } } /*============================================================================== * JSON Number Reader (IEEE-754) *============================================================================*/ /** Maximum exact pow10 exponent for double value. */ #define F64_POW10_EXP_MAX_EXACT 22 /** Cached pow10 table. */ static const f64 f64_pow10_table[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22 }; /** Read a JSON number. 1. This function assume that the floating-point number is in IEEE-754 format. 2. This function support uint64/int64/double number. If an integer number cannot fit in uint64/int64, it will returns as a double number. If a double number is infinite, the return value is based on flag. 3. This function (with inline attribute) may generate a lot of instructions. */ static_inline bool read_number(u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg) { #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) #define return_0() do { \ val->tag = YYJSON_TYPE_NUM | (u8)((u8)sign << 3); \ val->uni.u64 = 0; \ *end = cur; return true; \ } while (false) #define return_i64(_v) do { \ val->tag = YYJSON_TYPE_NUM | (u8)((u8)sign << 3); \ val->uni.u64 = (u64)(sign ? (u64)(~(_v) + 1) : (u64)(_v)); \ *end = cur; return true; \ } while (false) #define return_f64(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.f64 = sign ? -(f64)(_v) : (f64)(_v); \ *end = cur; return true; \ } while (false) #define return_f64_bin(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.u64 = ((u64)sign << 63) | (u64)(_v); \ *end = cur; return true; \ } while (false) #define return_inf() do { \ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); \ if (has_read_flag(ALLOW_INF_AND_NAN)) return_f64_bin(F64_RAW_INF); \ else return_err(hdr, "number is infinity when parsed as double"); \ } while (false) #define return_raw() do { \ if (*pre) **pre = '\0'; /* add null-terminator for previous raw string */ \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) u8 *sig_cut = NULL; /* significant part cutting position for long number */ u8 *sig_end = NULL; /* significant part ending position */ u8 *dot_pos = NULL; /* decimal point position */ u64 sig = 0; /* significant part of the number */ i32 exp = 0; /* exponent part of the number */ bool exp_sign; /* temporary exponent sign from literal part */ i64 exp_sig = 0; /* temporary exponent number from significant part */ i64 exp_lit = 0; /* temporary exponent number from exponent literal part */ u64 num; /* temporary number for reading */ u8 *tmp; /* temporary cursor for reading */ u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; bool sign; /* read number as raw string if has `YYJSON_READ_NUMBER_AS_RAW` flag */ if (unlikely(pre && !has_read_flag(BIGNUM_AS_RAW))) { return read_number_raw(ptr, pre, flg, val, msg); } sign = (*hdr == '-'); cur += sign; /* begin with a leading zero or non-digit */ if (unlikely(!digi_is_nonzero(*cur))) { /* 0 or non-digit char */ if (unlikely(*cur != '0')) { /* non-digit char */ if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_inf_or_nan(sign, &cur, pre, val)) { *end = cur; return true; } } return_err(cur, "no digit after minus sign"); } /* begin with 0 */ if (likely(!digi_is_digit_or_fp(*++cur))) return_0(); if (likely(*cur == '.')) { dot_pos = cur++; if (unlikely(!digi_is_digit(*cur))) { return_err(cur, "no digit after decimal point"); } while (unlikely(*cur == '0')) cur++; if (likely(digi_is_digit(*cur))) { /* first non-zero digit after decimal point */ sig = (u64)(*cur - '0'); /* read first digit */ cur--; goto digi_frac_1; /* continue read fraction part */ } } if (unlikely(digi_is_digit(*cur))) { return_err(cur - 1, "number with leading zero is not allowed"); } if (unlikely(digi_is_exp(*cur))) { /* 0 with any exponent is still 0 */ cur += (usize)1 + digi_is_sign(cur[1]); if (unlikely(!digi_is_digit(*cur))) { return_err(cur, "no digit after exponent sign"); } while (digi_is_digit(*++cur)); } return_f64_bin(0); } /* begin with non-zero digit */ sig = (u64)(*cur - '0'); /* Read integral part, same as the following code. for (int i = 1; i <= 18; i++) { num = cur[i] - '0'; if (num <= 9) sig = num + sig * 10; else goto digi_sepr_i; } */ #define expr_intg(i) \ if (likely((num = (u64)(cur[i] - (u8)'0')) <= 9)) sig = num + sig * 10; \ else { goto digi_sepr_##i; } repeat_in_1_18(expr_intg) #undef expr_intg cur += 19; /* skip continuous 19 digits */ if (!digi_is_digit_or_fp(*cur)) { /* this number is an integer consisting of 19 digits */ if (sign && (sig > ((u64)1 << 63))) { /* overflow */ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); return_f64(normalized_u64_to_f64(sig)); } return_i64(sig); } goto digi_intg_more; /* read more digits in integral part */ /* process first non-digit character */ #define expr_sepr(i) \ digi_sepr_##i: \ if (likely(!digi_is_fp(cur[i]))) { cur += i; return_i64(sig); } \ dot_pos = cur + i; \ if (likely(cur[i] == '.')) goto digi_frac_##i; \ cur += i; sig_end = cur; goto digi_exp_more; repeat_in_1_18(expr_sepr) #undef expr_sepr /* read fraction part */ #define expr_frac(i) \ digi_frac_##i: \ if (likely((num = (u64)(cur[i + 1] - (u8)'0')) <= 9)) \ sig = num + sig * 10; \ else { goto digi_stop_##i; } repeat_in_1_18(expr_frac) #undef expr_frac cur += 20; /* skip 19 digits and 1 decimal point */ if (!digi_is_digit(*cur)) goto digi_frac_end; /* fraction part end */ goto digi_frac_more; /* read more digits in fraction part */ /* significant part end */ #define expr_stop(i) \ digi_stop_##i: \ cur += i + 1; \ goto digi_frac_end; repeat_in_1_18(expr_stop) #undef expr_stop /* read more digits in integral part */ digi_intg_more: if (digi_is_digit(*cur)) { if (!digi_is_digit_or_fp(cur[1])) { /* this number is an integer consisting of 20 digits */ num = (u64)(*cur - '0'); if ((sig < (U64_MAX / 10)) || (sig == (U64_MAX / 10) && num <= (U64_MAX % 10))) { sig = num + sig * 10; cur++; /* convert to double if overflow */ if (sign) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); return_f64(normalized_u64_to_f64(sig)); } return_i64(sig); } } } if (digi_is_exp(*cur)) { dot_pos = cur; goto digi_exp_more; } if (*cur == '.') { dot_pos = cur++; if (!digi_is_digit(*cur)) { return_err(cur, "no digit after decimal point"); } } /* read more digits in fraction part */ digi_frac_more: sig_cut = cur; /* too large to fit in u64, excess digits need to be cut */ sig += (*cur >= '5'); /* round */ while (digi_is_digit(*++cur)); if (!dot_pos) { if (!digi_is_fp(*cur) && has_read_flag(BIGNUM_AS_RAW)) { return_raw(); /* it's a large integer */ } dot_pos = cur; if (*cur == '.') { if (!digi_is_digit(*++cur)) { return_err(cur, "no digit after decimal point"); } while (digi_is_digit(*cur)) cur++; } } exp_sig = (i64)(dot_pos - sig_cut); exp_sig += (dot_pos < sig_cut); /* ignore trailing zeros */ tmp = cur - 1; while (*tmp == '0' || *tmp == '.') tmp--; if (tmp < sig_cut) { sig_cut = NULL; } else { sig_end = cur; } if (digi_is_exp(*cur)) goto digi_exp_more; goto digi_exp_finish; /* fraction part end */ digi_frac_end: if (unlikely(dot_pos + 1 == cur)) { return_err(cur, "no digit after decimal point"); } sig_end = cur; exp_sig = -(i64)((u64)(cur - dot_pos) - 1); if (likely(!digi_is_exp(*cur))) { if (unlikely(exp_sig < F64_MIN_DEC_EXP - 19)) { return_f64_bin(0); /* underflow */ } exp = (i32)exp_sig; goto digi_finish; } else { goto digi_exp_more; } /* read exponent part */ digi_exp_more: exp_sign = (*++cur == '-'); cur += digi_is_sign(*cur); if (unlikely(!digi_is_digit(*cur))) { return_err(cur, "no digit after exponent sign"); } while (*cur == '0') cur++; /* read exponent literal */ tmp = cur; while (digi_is_digit(*cur)) { exp_lit = (i64)((u8)(*cur++ - '0') + (u64)exp_lit * 10); } if (unlikely(cur - tmp >= U64_SAFE_DIG)) { if (exp_sign) { return_f64_bin(0); /* underflow */ } else { return_inf(); /* overflow */ } } exp_sig += exp_sign ? -exp_lit : exp_lit; /* validate exponent value */ digi_exp_finish: if (unlikely(exp_sig < F64_MIN_DEC_EXP - 19)) { return_f64_bin(0); /* underflow */ } if (unlikely(exp_sig > F64_MAX_DEC_EXP)) { return_inf(); /* overflow */ } exp = (i32)exp_sig; /* all digit read finished */ digi_finish: /* Fast path 1: 1. The floating-point number calculation should be accurate, see the comments of macro `YYJSON_DOUBLE_MATH_CORRECT`. 2. Correct rounding should be performed (fegetround() == FE_TONEAREST). 3. The input of floating point number calculation does not lose precision, which means: 64 - leading_zero(input) - trailing_zero(input) < 53. We don't check all available inputs here, because that would make the code more complicated, and not friendly to branch predictor. */ #if YYJSON_DOUBLE_MATH_CORRECT if (sig < ((u64)1 << 53) && exp >= -F64_POW10_EXP_MAX_EXACT && exp <= +F64_POW10_EXP_MAX_EXACT) { f64 dbl = (f64)sig; if (exp < 0) { dbl /= f64_pow10_table[-exp]; } else { dbl *= f64_pow10_table[+exp]; } return_f64(dbl); } #endif /* Fast path 2: To keep it simple, we only accept normal number here, let the slow path to handle subnormal and infinity number. */ if (likely(!sig_cut && exp > -F64_MAX_DEC_EXP + 1 && exp < +F64_MAX_DEC_EXP - 20)) { /* The result value is exactly equal to (sig * 10^exp), the exponent part (10^exp) can be converted to (sig2 * 2^exp2). The sig2 can be an infinite length number, only the highest 128 bits is cached in the pow10_sig_table. Now we have these bits: sig1 (normalized 64bit) : aaaaaaaa sig2 (higher 64bit) : bbbbbbbb sig2_ext (lower 64bit) : cccccccc sig2_cut (extra unknown bits) : dddddddddddd.... And the calculation process is: ---------------------------------------- aaaaaaaa * bbbbbbbbccccccccdddddddddddd.... ---------------------------------------- abababababababab + acacacacacacacac + adadadadadadadadadad.... ---------------------------------------- [hi____][lo____] + [hi2___][lo2___] + [unknown___________....] ---------------------------------------- The addition with carry may affect higher bits, but if there is a 0 in higher bits, the bits higher than 0 will not be affected. `lo2` + `unknown` may get a carry bit and may affect `hi2`, the max value of `hi2` is 0xFFFFFFFFFFFFFFFE, so `hi2` will not overflow. `lo` + `hi2` may also get a carry bit and may affect `hi`, but only the highest significant 53 bits of `hi` is needed. If there is a 0 in the lower bits of `hi`, then all the following bits can be dropped. To convert the result to IEEE-754 double number, we need to perform correct rounding: 1. if bit 54 is 0, round down, 2. if bit 54 is 1 and any bit beyond bit 54 is 1, round up, 3. if bit 54 is 1 and all bits beyond bit 54 are 0, round to even, as the extra bits is unknown, this case will not be handled here. */ u64 raw; u64 sig1, sig2, sig2_ext, hi, lo, hi2, lo2, add, bits; i32 exp2; u32 lz; bool exact = false, carry, round_up; /* convert (10^exp) to (sig2 * 2^exp2) */ pow10_table_get_sig(exp, &sig2, &sig2_ext); pow10_table_get_exp(exp, &exp2); /* normalize and multiply */ lz = u64_lz_bits(sig); sig1 = sig << lz; exp2 -= (i32)lz; u128_mul(sig1, sig2, &hi, &lo); /* The `hi` is in range [0x4000000000000000, 0xFFFFFFFFFFFFFFFE], To get normalized value, `hi` should be shifted to the left by 0 or 1. The highest significant 53 bits is used by IEEE-754 double number, and the bit 54 is used to detect rounding direction. The lowest (64 - 54 - 1) bits is used to check whether it contains 0. */ bits = hi & (((u64)1 << (64 - 54 - 1)) - 1); if (bits - 1 < (((u64)1 << (64 - 54 - 1)) - 2)) { /* (bits != 0 && bits != 0x1FF) => (bits - 1 < 0x1FF - 1) The `bits` is not zero, so we don't need to check `round to even` case. The `bits` contains bit `0`, so we can drop the extra bits after `0`. */ exact = true; } else { /* (bits == 0 || bits == 0x1FF) The `bits` is filled with all `0` or all `1`, so we need to check lower bits with another 64-bit multiplication. */ u128_mul(sig1, sig2_ext, &hi2, &lo2); add = lo + hi2; if (add + 1 > (u64)1) { /* (add != 0 && add != U64_MAX) => (add + 1 > 1) The `add` is not zero, so we don't need to check `round to even` case. The `add` contains bit `0`, so we can drop the extra bits after `0`. The `hi` cannot be U64_MAX, so it will not overflow. */ carry = add < lo || add < hi2; hi += carry; exact = true; } } if (exact) { /* normalize */ lz = hi < ((u64)1 << 63); hi <<= lz; exp2 -= (i32)lz; exp2 += 64; /* test the bit 54 and get rounding direction */ round_up = (hi & ((u64)1 << (64 - 54))) > (u64)0; hi += (round_up ? ((u64)1 << (64 - 54)) : (u64)0); /* test overflow */ if (hi < ((u64)1 << (64 - 54))) { hi = ((u64)1 << 63); exp2 += 1; } /* This is a normal number, convert it to IEEE-754 format. */ hi >>= F64_BITS - F64_SIG_FULL_BITS; exp2 += F64_BITS - F64_SIG_FULL_BITS + F64_SIG_BITS; exp2 += F64_EXP_BIAS; raw = ((u64)exp2 << F64_SIG_BITS) | (hi & F64_SIG_MASK); return_f64_bin(raw); } } /* Slow path: read double number exactly with diyfp. 1. Use cached diyfp to get an approximation value. 2. Use bigcomp to check the approximation value if needed. This algorithm refers to google's double-conversion project: https://github.com/google/double-conversion */ { const i32 ERR_ULP_LOG = 3; const i32 ERR_ULP = 1 << ERR_ULP_LOG; const i32 ERR_CACHED_POW = ERR_ULP / 2; const i32 ERR_MUL_FIXED = ERR_ULP / 2; const i32 DIY_SIG_BITS = 64; const i32 EXP_BIAS = F64_EXP_BIAS + F64_SIG_BITS; const i32 EXP_SUBNORMAL = -EXP_BIAS + 1; u64 fp_err; u32 bits; i32 order_of_magnitude; i32 effective_significand_size; i32 precision_digits_count; u64 precision_bits; u64 half_way; u64 raw; diy_fp fp, fp_upper; bigint big_full, big_comp; i32 cmp; fp.sig = sig; fp.exp = 0; fp_err = sig_cut ? (u64)(ERR_ULP / 2) : (u64)0; /* normalize */ bits = u64_lz_bits(fp.sig); fp.sig <<= bits; fp.exp -= (i32)bits; fp_err <<= bits; /* multiply and add error */ fp = diy_fp_mul(fp, diy_fp_get_cached_pow10(exp)); fp_err += (u64)ERR_CACHED_POW + (fp_err != 0) + (u64)ERR_MUL_FIXED; /* normalize */ bits = u64_lz_bits(fp.sig); fp.sig <<= bits; fp.exp -= (i32)bits; fp_err <<= bits; /* effective significand */ order_of_magnitude = DIY_SIG_BITS + fp.exp; if (likely(order_of_magnitude >= EXP_SUBNORMAL + F64_SIG_FULL_BITS)) { effective_significand_size = F64_SIG_FULL_BITS; } else if (order_of_magnitude <= EXP_SUBNORMAL) { effective_significand_size = 0; } else { effective_significand_size = order_of_magnitude - EXP_SUBNORMAL; } /* precision digits count */ precision_digits_count = DIY_SIG_BITS - effective_significand_size; if (unlikely(precision_digits_count + ERR_ULP_LOG >= DIY_SIG_BITS)) { i32 shr = (precision_digits_count + ERR_ULP_LOG) - DIY_SIG_BITS + 1; fp.sig >>= shr; fp.exp += shr; fp_err = (fp_err >> shr) + 1 + (u32)ERR_ULP; precision_digits_count -= shr; } /* half way */ precision_bits = fp.sig & (((u64)1 << precision_digits_count) - 1); precision_bits *= (u32)ERR_ULP; half_way = (u64)1 << (precision_digits_count - 1); half_way *= (u32)ERR_ULP; /* rounding */ fp.sig >>= precision_digits_count; fp.sig += (precision_bits >= half_way + fp_err); fp.exp += precision_digits_count; /* get IEEE double raw value */ raw = diy_fp_to_ieee_raw(fp); if (unlikely(raw == F64_RAW_INF)) return_inf(); if (likely(precision_bits <= half_way - fp_err || precision_bits >= half_way + fp_err)) { return_f64_bin(raw); /* number is accurate */ } /* now the number is the correct value, or the next lower value */ /* upper boundary */ if (raw & F64_EXP_MASK) { fp_upper.sig = (raw & F64_SIG_MASK) + ((u64)1 << F64_SIG_BITS); fp_upper.exp = (i32)((raw & F64_EXP_MASK) >> F64_SIG_BITS); } else { fp_upper.sig = (raw & F64_SIG_MASK); fp_upper.exp = 1; } fp_upper.exp -= F64_EXP_BIAS + F64_SIG_BITS; fp_upper.sig <<= 1; fp_upper.exp -= 1; fp_upper.sig += 1; /* add half ulp */ /* compare with bigint */ bigint_set_buf(&big_full, sig, &exp, sig_cut, sig_end, dot_pos); bigint_set_u64(&big_comp, fp_upper.sig); if (exp >= 0) { bigint_mul_pow10(&big_full, +exp); } else { bigint_mul_pow10(&big_comp, -exp); } if (fp_upper.exp > 0) { bigint_mul_pow2(&big_comp, (u32)+fp_upper.exp); } else { bigint_mul_pow2(&big_full, (u32)-fp_upper.exp); } cmp = bigint_cmp(&big_full, &big_comp); if (likely(cmp != 0)) { /* round down or round up */ raw += (cmp > 0); } else { /* falls midway, round to even */ raw += (raw & 1); } if (unlikely(raw == F64_RAW_INF)) return_inf(); return_f64_bin(raw); } #undef return_err #undef return_inf #undef return_0 #undef return_i64 #undef return_f64 #undef return_f64_bin #undef return_raw } #else /* FP_READER */ /** Read a JSON number. This is a fallback function if the custom number reader is disabled. This function use libc's strtod() to read floating-point number. */ static_inline bool read_number(u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg) { #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) #define return_0() do { \ val->tag = YYJSON_TYPE_NUM | (u64)((u8)sign << 3); \ val->uni.u64 = 0; \ *end = cur; return true; \ } while (false) #define return_i64(_v) do { \ val->tag = YYJSON_TYPE_NUM | (u64)((u8)sign << 3); \ val->uni.u64 = (u64)(sign ? (u64)(~(_v) + 1) : (u64)(_v)); \ *end = cur; return true; \ } while (false) #define return_f64(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.f64 = sign ? -(f64)(_v) : (f64)(_v); \ *end = cur; return true; \ } while (false) #define return_f64_bin(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.u64 = ((u64)sign << 63) | (u64)(_v); \ *end = cur; return true; \ } while (false) #define return_inf() do { \ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); \ if (has_read_flag(ALLOW_INF_AND_NAN)) return_f64_bin(F64_RAW_INF); \ else return_err(hdr, "number is infinity when parsed as double"); \ } while (false) #define return_raw() do { \ if (*pre) **pre = '\0'; /* add null-terminator for previous raw string */ \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) u64 sig, num; u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; u8 *dot = NULL; u8 *f64_end = NULL; bool sign; /* read number as raw string if has `YYJSON_READ_NUMBER_AS_RAW` flag */ if (unlikely(pre && !has_read_flag(BIGNUM_AS_RAW))) { return read_number_raw(ptr, pre, flg, val, msg); } sign = (*hdr == '-'); cur += sign; sig = (u8)(*cur - '0'); /* read first digit, check leading zero */ if (unlikely(!digi_is_digit(*cur))) { if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_inf_or_nan(sign, &cur, pre, val)) { *end = cur; return true; } } return_err(cur, "no digit after minus sign"); } if (*cur == '0') { cur++; if (unlikely(digi_is_digit(*cur))) { return_err(cur - 1, "number with leading zero is not allowed"); } if (!digi_is_fp(*cur)) return_0(); goto read_double; } /* read continuous digits, up to 19 characters */ #define expr_intg(i) \ if (likely((num = (u64)(cur[i] - (u8)'0')) <= 9)) sig = num + sig * 10; \ else { cur += i; goto intg_end; } repeat_in_1_18(expr_intg) #undef expr_intg /* here are 19 continuous digits, skip them */ cur += 19; if (digi_is_digit(cur[0]) && !digi_is_digit_or_fp(cur[1])) { /* this number is an integer consisting of 20 digits */ num = (u8)(*cur - '0'); if ((sig < (U64_MAX / 10)) || (sig == (U64_MAX / 10) && num <= (U64_MAX % 10))) { sig = num + sig * 10; cur++; if (sign) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); return_f64(normalized_u64_to_f64(sig)); } return_i64(sig); } } intg_end: /* continuous digits ended */ if (!digi_is_digit_or_fp(*cur)) { /* this number is an integer consisting of 1 to 19 digits */ if (sign && (sig > ((u64)1 << 63))) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); return_f64(normalized_u64_to_f64(sig)); } return_i64(sig); } read_double: /* this number should be read as double */ while (digi_is_digit(*cur)) cur++; if (!digi_is_fp(*cur) && has_read_flag(BIGNUM_AS_RAW)) { return_raw(); /* it's a large integer */ } if (*cur == '.') { /* skip fraction part */ dot = cur; cur++; if (!digi_is_digit(*cur)) { return_err(cur, "no digit after decimal point"); } cur++; while (digi_is_digit(*cur)) cur++; } if (digi_is_exp(*cur)) { /* skip exponent part */ cur += 1 + digi_is_sign(cur[1]); if (!digi_is_digit(*cur)) { return_err(cur, "no digit after exponent sign"); } cur++; while (digi_is_digit(*cur)) cur++; } /* libc's strtod() is used to parse the floating-point number. Note that the decimal point character used by strtod() is locale-dependent, and the rounding direction may affected by fesetround(). For currently known locales, (en, zh, ja, ko, am, he, hi) use '.' as the decimal point, while other locales use ',' as the decimal point. Here strtod() is called twice for different locales, but if another thread happens calls setlocale() between two strtod(), parsing may still fail. */ val->uni.f64 = strtod((const char *)hdr, (char **)&f64_end); if (unlikely(f64_end != cur)) { /* replace '.' with ',' for locale */ bool cut = (*cur == ','); if (cut) *cur = ' '; if (dot) *dot = ','; val->uni.f64 = strtod((const char *)hdr, (char **)&f64_end); /* restore ',' to '.' */ if (cut) *cur = ','; if (dot) *dot = '.'; if (unlikely(f64_end != cur)) { return_err(hdr, "strtod() failed to parse the number"); } } if (unlikely(val->uni.f64 >= HUGE_VAL || val->uni.f64 <= -HUGE_VAL)) { return_inf(); } val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; *end = cur; return true; #undef return_err #undef return_0 #undef return_i64 #undef return_f64 #undef return_f64_bin #undef return_inf #undef return_raw } #endif /* FP_READER */ /*============================================================================== * JSON String Reader *============================================================================*/ /** Read a JSON string. @param ptr The head pointer of string before '"' prefix (inout). @param lst JSON last position. @param inv Allow invalid unicode. @param val The string value to be written. @param msg The error message pointer. @return Whether success. */ static_inline bool read_string(u8 **ptr, u8 *lst, bool inv, yyjson_val *val, const char **msg) { /* Each unicode code point is encoded as 1 to 4 bytes in UTF-8 encoding, we use 4-byte mask and pattern value to validate UTF-8 byte sequence, this requires the input data to have 4-byte zero padding. --------------------------------------------------- 1 byte unicode range [U+0000, U+007F] unicode min [.......0] unicode max [.1111111] bit pattern [0.......] --------------------------------------------------- 2 byte unicode range [U+0080, U+07FF] unicode min [......10 ..000000] unicode max [...11111 ..111111] bit require [...xxxx. ........] (1E 00) bit mask [xxx..... xx......] (E0 C0) bit pattern [110..... 10......] (C0 80) --------------------------------------------------- 3 byte unicode range [U+0800, U+FFFF] unicode min [........ ..100000 ..000000] unicode max [....1111 ..111111 ..111111] bit require [....xxxx ..x..... ........] (0F 20 00) bit mask [xxxx.... xx...... xx......] (F0 C0 C0) bit pattern [1110.... 10...... 10......] (E0 80 80) --------------------------------------------------- 3 byte invalid (reserved for surrogate halves) unicode range [U+D800, U+DFFF] unicode min [....1101 ..100000 ..000000] unicode max [....1101 ..111111 ..111111] bit mask [....xxxx ..x..... ........] (0F 20 00) bit pattern [....1101 ..1..... ........] (0D 20 00) --------------------------------------------------- 4 byte unicode range [U+10000, U+10FFFF] unicode min [........ ...10000 ..000000 ..000000] unicode max [.....100 ..001111 ..111111 ..111111] bit require [.....xxx ..xx.... ........ ........] (07 30 00 00) bit mask [xxxxx... xx...... xx...... xx......] (F8 C0 C0 C0) bit pattern [11110... 10...... 10...... 10......] (F0 80 80 80) --------------------------------------------------- */ #if YYJSON_ENDIAN == YYJSON_BIG_ENDIAN const u32 b1_mask = 0x80000000UL; const u32 b1_patt = 0x00000000UL; const u32 b2_mask = 0xE0C00000UL; const u32 b2_patt = 0xC0800000UL; const u32 b2_requ = 0x1E000000UL; const u32 b3_mask = 0xF0C0C000UL; const u32 b3_patt = 0xE0808000UL; const u32 b3_requ = 0x0F200000UL; const u32 b3_erro = 0x0D200000UL; const u32 b4_mask = 0xF8C0C0C0UL; const u32 b4_patt = 0xF0808080UL; const u32 b4_requ = 0x07300000UL; const u32 b4_err0 = 0x04000000UL; const u32 b4_err1 = 0x03300000UL; #elif YYJSON_ENDIAN == YYJSON_LITTLE_ENDIAN const u32 b1_mask = 0x00000080UL; const u32 b1_patt = 0x00000000UL; const u32 b2_mask = 0x0000C0E0UL; const u32 b2_patt = 0x000080C0UL; const u32 b2_requ = 0x0000001EUL; const u32 b3_mask = 0x00C0C0F0UL; const u32 b3_patt = 0x008080E0UL; const u32 b3_requ = 0x0000200FUL; const u32 b3_erro = 0x0000200DUL; const u32 b4_mask = 0xC0C0C0F8UL; const u32 b4_patt = 0x808080F0UL; const u32 b4_requ = 0x00003007UL; const u32 b4_err0 = 0x00000004UL; const u32 b4_err1 = 0x00003003UL; #else /* this should be evaluated at compile-time */ v32_uni b1_mask_uni = {{ 0x80, 0x00, 0x00, 0x00 }}; v32_uni b1_patt_uni = {{ 0x00, 0x00, 0x00, 0x00 }}; v32_uni b2_mask_uni = {{ 0xE0, 0xC0, 0x00, 0x00 }}; v32_uni b2_patt_uni = {{ 0xC0, 0x80, 0x00, 0x00 }}; v32_uni b2_requ_uni = {{ 0x1E, 0x00, 0x00, 0x00 }}; v32_uni b3_mask_uni = {{ 0xF0, 0xC0, 0xC0, 0x00 }}; v32_uni b3_patt_uni = {{ 0xE0, 0x80, 0x80, 0x00 }}; v32_uni b3_requ_uni = {{ 0x0F, 0x20, 0x00, 0x00 }}; v32_uni b3_erro_uni = {{ 0x0D, 0x20, 0x00, 0x00 }}; v32_uni b4_mask_uni = {{ 0xF8, 0xC0, 0xC0, 0xC0 }}; v32_uni b4_patt_uni = {{ 0xF0, 0x80, 0x80, 0x80 }}; v32_uni b4_requ_uni = {{ 0x07, 0x30, 0x00, 0x00 }}; v32_uni b4_err0_uni = {{ 0x04, 0x00, 0x00, 0x00 }}; v32_uni b4_err1_uni = {{ 0x03, 0x30, 0x00, 0x00 }}; u32 b1_mask = b1_mask_uni.u; u32 b1_patt = b1_patt_uni.u; u32 b2_mask = b2_mask_uni.u; u32 b2_patt = b2_patt_uni.u; u32 b2_requ = b2_requ_uni.u; u32 b3_mask = b3_mask_uni.u; u32 b3_patt = b3_patt_uni.u; u32 b3_requ = b3_requ_uni.u; u32 b3_erro = b3_erro_uni.u; u32 b4_mask = b4_mask_uni.u; u32 b4_patt = b4_patt_uni.u; u32 b4_requ = b4_requ_uni.u; u32 b4_err0 = b4_err0_uni.u; u32 b4_err1 = b4_err1_uni.u; #endif #define is_valid_seq_1(uni) ( \ ((uni & b1_mask) == b1_patt) \ ) #define is_valid_seq_2(uni) ( \ ((uni & b2_mask) == b2_patt) && \ ((uni & b2_requ)) \ ) #define is_valid_seq_3(uni) ( \ ((uni & b3_mask) == b3_patt) && \ ((tmp = (uni & b3_requ))) && \ ((tmp != b3_erro)) \ ) #define is_valid_seq_4(uni) ( \ ((uni & b4_mask) == b4_patt) && \ ((tmp = (uni & b4_requ))) && \ ((tmp & b4_err0) == 0 || (tmp & b4_err1) == 0) \ ) #define return_err(_end, _msg) do { \ *msg = _msg; \ *end = _end; \ return false; \ } while (false) u8 *cur = *ptr; u8 **end = ptr; u8 *src = ++cur, *dst, *pos; u16 hi, lo; u32 uni, tmp; skip_ascii: /* Most strings have no escaped characters, so we can jump them quickly. */ skip_ascii_begin: /* We want to make loop unrolling, as shown in the following code. Some compiler may not generate instructions as expected, so we rewrite it with explicit goto statements. We hope the compiler can generate instructions like this: https://godbolt.org/z/8vjsYq while (true) repeat16({ if (likely(!(char_is_ascii_stop(*src)))) src++; else break; }) */ #define expr_jump(i) \ if (likely(!char_is_ascii_stop(src[i]))) {} \ else goto skip_ascii_stop##i; #define expr_stop(i) \ skip_ascii_stop##i: \ src += i; \ goto skip_ascii_end; repeat16_incr(expr_jump) src += 16; goto skip_ascii_begin; repeat16_incr(expr_stop) #undef expr_jump #undef expr_stop skip_ascii_end: /* GCC may store src[i] in a register at each line of expr_jump(i) above. These instructions are useless and will degrade performance. This inline asm is a hint for gcc: "the memory has been modified, do not cache it". MSVC, Clang, ICC can generate expected instructions without this hint. */ #if YYJSON_IS_REAL_GCC __asm__ volatile("":"=m"(*src)); #endif if (likely(*src == '"')) { val->tag = ((u64)(src - cur) << YYJSON_TAG_BIT) | (u64)(YYJSON_TYPE_STR); val->uni.str = (const char *)cur; *src = '\0'; *end = src + 1; return true; } skip_utf8: if (*src & 0x80) { /* non-ASCII character */ /* Non-ASCII character appears here, which means that the text is likely to be written in non-English or emoticons. According to some common data set statistics, byte sequences of the same length may appear consecutively. We process the byte sequences of the same length in each loop, which is more friendly to branch prediction. */ pos = src; #if YYJSON_DISABLE_UTF8_VALIDATION while (true) repeat8({ if (likely((*src & 0xF0) == 0xE0)) src += 3; else break; }) if (*src < 0x80) goto skip_ascii; while (true) repeat8({ if (likely((*src & 0xE0) == 0xC0)) src += 2; else break; }) while (true) repeat8({ if (likely((*src & 0xF8) == 0xF0)) src += 4; else break; }) #else uni = byte_load_4(src); while (is_valid_seq_3(uni)) { src += 3; uni = byte_load_4(src); } if (is_valid_seq_1(uni)) goto skip_ascii; while (is_valid_seq_2(uni)) { src += 2; uni = byte_load_4(src); } while (is_valid_seq_4(uni)) { src += 4; uni = byte_load_4(src); } #endif if (false) { if (!inv) return_err(src, "invalid UTF-8 encoding in string"); ++src; } goto skip_ascii; } /* The escape character appears, we need to copy it. */ dst = src; copy_escape: if (likely(*src == '\\')) { switch (*++src) { case '"': *dst++ = '"'; src++; break; case '\\': *dst++ = '\\'; src++; break; case '/': *dst++ = '/'; src++; break; case 'b': *dst++ = '\b'; src++; break; case 'f': *dst++ = '\f'; src++; break; case 'n': *dst++ = '\n'; src++; break; case 'r': *dst++ = '\r'; src++; break; case 't': *dst++ = '\t'; src++; break; case 'u': if (unlikely(!read_hex_u16(++src, &hi))) { return_err(src - 2, "invalid escaped sequence in string"); } src += 4; if (likely((hi & 0xF800) != 0xD800)) { /* a BMP character */ if (hi >= 0x800) { *dst++ = (u8)(0xE0 | (hi >> 12)); *dst++ = (u8)(0x80 | ((hi >> 6) & 0x3F)); *dst++ = (u8)(0x80 | (hi & 0x3F)); } else if (hi >= 0x80) { *dst++ = (u8)(0xC0 | (hi >> 6)); *dst++ = (u8)(0x80 | (hi & 0x3F)); } else { *dst++ = (u8)hi; } } else { /* a non-BMP character, represented as a surrogate pair */ if (unlikely((hi & 0xFC00) != 0xD800)) { return_err(src - 6, "invalid high surrogate in string"); } if (unlikely(!byte_match_2(src, "\\u"))) { return_err(src, "no low surrogate in string"); } if (unlikely(!read_hex_u16(src + 2, &lo))) { return_err(src, "invalid escaped sequence in string"); } if (unlikely((lo & 0xFC00) != 0xDC00)) { return_err(src, "invalid low surrogate in string"); } uni = ((((u32)hi - 0xD800) << 10) | ((u32)lo - 0xDC00)) + 0x10000; *dst++ = (u8)(0xF0 | (uni >> 18)); *dst++ = (u8)(0x80 | ((uni >> 12) & 0x3F)); *dst++ = (u8)(0x80 | ((uni >> 6) & 0x3F)); *dst++ = (u8)(0x80 | (uni & 0x3F)); src += 6; } break; default: return_err(src, "invalid escaped character in string"); } } else if (likely(*src == '"')) { val->tag = ((u64)(dst - cur) << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = (const char *)cur; *dst = '\0'; *end = src + 1; return true; } else { if (!inv) return_err(src, "unexpected control character in string"); if (src >= lst) return_err(src, "unclosed string"); *dst++ = *src++; } copy_ascii: /* Copy continuous ASCII, loop unrolling, same as the following code: while (true) repeat16({ if (unlikely(char_is_ascii_stop(*src))) break; *dst++ = *src++; }) */ #if YYJSON_IS_REAL_GCC # define expr_jump(i) \ if (likely(!(char_is_ascii_stop(src[i])))) {} \ else { __asm__ volatile("":"=m"(src[i])); goto copy_ascii_stop_##i; } #else # define expr_jump(i) \ if (likely(!(char_is_ascii_stop(src[i])))) {} \ else { goto copy_ascii_stop_##i; } #endif repeat16_incr(expr_jump) #undef expr_jump byte_move_16(dst, src); src += 16; dst += 16; goto copy_ascii; /* The memory will be moved forward by at least 1 byte. So the `byte_move` can be one byte more than needed to reduce the number of instructions. */ copy_ascii_stop_0: goto copy_utf8; copy_ascii_stop_1: byte_move_2(dst, src); src += 1; dst += 1; goto copy_utf8; copy_ascii_stop_2: byte_move_2(dst, src); src += 2; dst += 2; goto copy_utf8; copy_ascii_stop_3: byte_move_4(dst, src); src += 3; dst += 3; goto copy_utf8; copy_ascii_stop_4: byte_move_4(dst, src); src += 4; dst += 4; goto copy_utf8; copy_ascii_stop_5: byte_move_4(dst, src); byte_move_2(dst + 4, src + 4); src += 5; dst += 5; goto copy_utf8; copy_ascii_stop_6: byte_move_4(dst, src); byte_move_2(dst + 4, src + 4); src += 6; dst += 6; goto copy_utf8; copy_ascii_stop_7: byte_move_8(dst, src); src += 7; dst += 7; goto copy_utf8; copy_ascii_stop_8: byte_move_8(dst, src); src += 8; dst += 8; goto copy_utf8; copy_ascii_stop_9: byte_move_8(dst, src); byte_move_2(dst + 8, src + 8); src += 9; dst += 9; goto copy_utf8; copy_ascii_stop_10: byte_move_8(dst, src); byte_move_2(dst + 8, src + 8); src += 10; dst += 10; goto copy_utf8; copy_ascii_stop_11: byte_move_8(dst, src); byte_move_4(dst + 8, src + 8); src += 11; dst += 11; goto copy_utf8; copy_ascii_stop_12: byte_move_8(dst, src); byte_move_4(dst + 8, src + 8); src += 12; dst += 12; goto copy_utf8; copy_ascii_stop_13: byte_move_8(dst, src); byte_move_4(dst + 8, src + 8); byte_move_2(dst + 12, src + 12); src += 13; dst += 13; goto copy_utf8; copy_ascii_stop_14: byte_move_8(dst, src); byte_move_4(dst + 8, src + 8); byte_move_2(dst + 12, src + 12); src += 14; dst += 14; goto copy_utf8; copy_ascii_stop_15: byte_move_16(dst, src); src += 15; dst += 15; goto copy_utf8; copy_utf8: if (*src & 0x80) { /* non-ASCII character */ pos = src; uni = byte_load_4(src); #if YYJSON_DISABLE_UTF8_VALIDATION while (true) repeat4({ if ((uni & b3_mask) == b3_patt) { byte_copy_4(dst, &uni); dst += 3; src += 3; uni = byte_load_4(src); } else break; }) if ((uni & b1_mask) == b1_patt) goto copy_ascii; while (true) repeat4({ if ((uni & b2_mask) == b2_patt) { byte_copy_2(dst, &uni); dst += 2; src += 2; uni = byte_load_4(src); } else break; }) while (true) repeat4({ if ((uni & b4_mask) == b4_patt) { byte_copy_4(dst, &uni); dst += 4; src += 4; uni = byte_load_4(src); } else break; }) #else while (is_valid_seq_3(uni)) { byte_copy_4(dst, &uni); dst += 3; src += 3; uni = byte_load_4(src); } if (is_valid_seq_1(uni)) goto copy_ascii; while (is_valid_seq_2(uni)) { byte_copy_2(dst, &uni); dst += 2; src += 2; uni = byte_load_4(src); } while (is_valid_seq_4(uni)) { byte_copy_4(dst, &uni); dst += 4; src += 4; uni = byte_load_4(src); } #endif if (false) { if (!inv) return_err(src, "invalid UTF-8 encoding in string"); goto copy_ascii_stop_1; } goto copy_ascii; } goto copy_escape; #undef return_err #undef is_valid_seq_1 #undef is_valid_seq_2 #undef is_valid_seq_3 #undef is_valid_seq_4 } /*============================================================================== * JSON Reader Implementation * * We use goto statements to build the finite state machine (FSM). * The FSM's state was held by program counter (PC) and the 'goto' make the * state transitions. *============================================================================*/ /** Read single value JSON document. */ static_noinline yyjson_doc *read_root_single(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ err->msg = "unexpected end of data"; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ err->msg = _msg; \ } \ if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) usize hdr_len; /* value count used by doc */ usize alc_num; /* value count capacity */ yyjson_val *val_hdr; /* the head of allocated values */ yyjson_val *val; /* current value */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_num = hdr_len + 1; /* single value */ val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_num * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val = val_hdr + hdr_len; raw = has_read_flag(NUMBER_AS_RAW) || has_read_flag(BIGNUM_AS_RAW); inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; if (char_is_number(*cur)) { if (likely(read_number(&cur, pre, flg, val, &msg))) goto doc_end; goto fail_number; } if (*cur == '"') { if (likely(read_string(&cur, end, inv, val, &msg))) goto doc_end; goto fail_string; } if (*cur == 't') { if (likely(read_true(&cur, val))) goto doc_end; goto fail_literal; } if (*cur == 'f') { if (likely(read_false(&cur, val))) goto doc_end; goto fail_literal; } if (*cur == 'n') { if (likely(read_null(&cur, val))) goto doc_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_nan(false, &cur, pre, val)) goto doc_end; } goto fail_literal; } if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_inf_or_nan(false, &cur, pre, val)) goto doc_end; } goto fail_character; doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { if (has_read_flag(ALLOW_COMMENTS)) { if (!skip_spaces_and_comments(&cur)) { if (byte_match_2(cur, "/*")) goto fail_comment; } } else { while (char_is_space(*cur)) cur++; } if (unlikely(cur < end)) goto fail_garbage; } if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; doc->alc = alc; doc->dat_read = (usize)(cur - hdr); doc->val_read = 1; doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; fail_string: return_err(cur, INVALID_STRING, msg); fail_number: return_err(cur, INVALID_NUMBER, msg); fail_alloc: return_err(cur, MEMORY_ALLOCATION, "memory allocation failed"); fail_literal: return_err(cur, LITERAL, "invalid literal"); fail_comment: return_err(cur, INVALID_COMMENT, "unclosed multiline comment"); fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); fail_recursion: return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef return_err } /** Read JSON document (accept all style, but optimized for minify). */ static_inline yyjson_doc *read_root_minify(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ err->msg = "unexpected end of data"; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ err->msg = _msg; \ } \ if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) #define val_incr() do { \ val++; \ if (unlikely(val >= val_end)) { \ usize alc_old = alc_len; \ alc_len += alc_len / 2; \ if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \ val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \ alc_old * sizeof(yyjson_val), \ alc_len * sizeof(yyjson_val)); \ if ((!val_tmp)) goto fail_alloc; \ val = val_tmp + (usize)(val - val_hdr); \ ctn = val_tmp + (usize)(ctn - val_hdr); \ val_hdr = val_tmp; \ val_end = val_tmp + (alc_len - 2); \ } \ } while (false) usize dat_len; /* data length in bytes, hint for allocator */ usize hdr_len; /* value count used by yyjson_doc */ usize alc_len; /* value count allocated */ usize alc_max; /* maximum value count for allocator */ usize ctn_len; /* the number of elements in current container */ yyjson_val *val_hdr; /* the head of allocated values */ yyjson_val *val_end; /* the end of allocated values */ yyjson_val *val_tmp; /* temporary pointer for realloc */ yyjson_val *val; /* current JSON value */ yyjson_val *ctn; /* current container */ yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ u32 container_depth = 0; /* limit on number of open array and map */ bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ dat_len = has_read_flag(STOP_WHEN_DONE) ? 256 : (usize)(end - cur); hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_max = USIZE_MAX / sizeof(yyjson_val); alc_len = hdr_len + (dat_len / YYJSON_READER_ESTIMATED_MINIFY_RATIO) + 4; alc_len = yyjson_min(alc_len, alc_max); val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_len * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val_end = val_hdr + (alc_len - 2); /* padding for key-value pair reading */ val = val_hdr + hdr_len; ctn = val; ctn_len = 0; raw = has_read_flag(NUMBER_AS_RAW) || has_read_flag(BIGNUM_AS_RAW); inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; if (*cur++ == '{') { ctn->tag = YYJSON_TYPE_OBJ; ctn->uni.ofs = 0; goto obj_key_begin; } else { ctn->tag = YYJSON_TYPE_ARR; ctn->uni.ofs = 0; goto arr_val_begin; } arr_begin: container_depth++; if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { goto fail_recursion; } /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); /* create a new array value, save parent container offset */ val_incr(); val->tag = YYJSON_TYPE_ARR; val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); /* push the new array value as current container */ ctn = val; ctn_len = 0; arr_val_begin: if (*cur == '{') { cur++; goto obj_begin; } if (*cur == '[') { cur++; goto arr_begin; } if (char_is_number(*cur)) { val_incr(); ctn_len++; if (likely(read_number(&cur, pre, flg, val, &msg))) goto arr_val_end; goto fail_number; } if (*cur == '"') { val_incr(); ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto arr_val_end; goto fail_string; } if (*cur == 't') { val_incr(); ctn_len++; if (likely(read_true(&cur, val))) goto arr_val_end; goto fail_literal; } if (*cur == 'f') { val_incr(); ctn_len++; if (likely(read_false(&cur, val))) goto arr_val_end; goto fail_literal; } if (*cur == 'n') { val_incr(); ctn_len++; if (likely(read_null(&cur, val))) goto arr_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_nan(false, &cur, pre, val)) goto arr_val_end; } goto fail_literal; } if (*cur == ']') { cur++; if (likely(ctn_len == 0)) goto arr_end; if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto arr_end; while (*cur != ',') cur--; goto fail_trailing_comma; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto arr_val_begin; } if (has_read_flag(ALLOW_INF_AND_NAN) && (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val_incr(); ctn_len++; if (read_inf_or_nan(false, &cur, pre, val)) goto arr_val_end; goto fail_character; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto arr_val_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; arr_val_end: if (*cur == ',') { cur++; goto arr_val_begin; } if (*cur == ']') { cur++; goto arr_end; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto arr_val_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto arr_val_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; arr_end: container_depth--; /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* save the next sibling value offset */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = ((ctn_len) << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; if (unlikely(ctn == ctn_parent)) goto doc_end; /* pop parent as current container */ ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { goto obj_val_end; } else { goto arr_val_end; } obj_begin: container_depth++; if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { goto fail_recursion; } /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); val_incr(); val->tag = YYJSON_TYPE_OBJ; /* offset to the parent */ val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); ctn = val; ctn_len = 0; obj_key_begin: if (likely(*cur == '"')) { val_incr(); ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_key_end; goto fail_string; } if (likely(*cur == '}')) { cur++; if (likely(ctn_len == 0)) goto obj_end; if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto obj_end; while (*cur != ',') cur--; goto fail_trailing_comma; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_key_begin; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_key_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_key_end: if (*cur == ':') { cur++; goto obj_val_begin; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_key_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_key_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_val_begin: if (*cur == '"') { val++; ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_val_end; goto fail_string; } if (char_is_number(*cur)) { val++; ctn_len++; if (likely(read_number(&cur, pre, flg, val, &msg))) goto obj_val_end; goto fail_number; } if (*cur == '{') { cur++; goto obj_begin; } if (*cur == '[') { cur++; goto arr_begin; } if (*cur == 't') { val++; ctn_len++; if (likely(read_true(&cur, val))) goto obj_val_end; goto fail_literal; } if (*cur == 'f') { val++; ctn_len++; if (likely(read_false(&cur, val))) goto obj_val_end; goto fail_literal; } if (*cur == 'n') { val++; ctn_len++; if (likely(read_null(&cur, val))) goto obj_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_nan(false, &cur, pre, val)) goto obj_val_end; } goto fail_literal; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_val_begin; } if (has_read_flag(ALLOW_INF_AND_NAN) && (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val++; ctn_len++; if (read_inf_or_nan(false, &cur, pre, val)) goto obj_val_end; goto fail_character; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_val_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_val_end: if (likely(*cur == ',')) { cur++; goto obj_key_begin; } if (likely(*cur == '}')) { cur++; goto obj_end; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_val_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_val_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_end: container_depth--; /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* point to the next value */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = (ctn_len << (YYJSON_TAG_BIT - 1)) | YYJSON_TYPE_OBJ; if (unlikely(ctn == ctn_parent)) goto doc_end; ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { goto obj_val_end; } else { goto arr_val_end; } doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { if (has_read_flag(ALLOW_COMMENTS)) { skip_spaces_and_comments(&cur); if (byte_match_2(cur, "/*")) goto fail_comment; } else { while (char_is_space(*cur)) cur++; } if (unlikely(cur < end)) goto fail_garbage; } if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; doc->alc = alc; doc->dat_read = (usize)(cur - hdr); doc->val_read = (usize)((val - doc->root) + 1); doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; fail_string: return_err(cur, INVALID_STRING, msg); fail_number: return_err(cur, INVALID_NUMBER, msg); fail_alloc: return_err(cur, MEMORY_ALLOCATION, "memory allocation failed"); fail_trailing_comma: return_err(cur, JSON_STRUCTURE, "trailing comma is not allowed"); fail_literal: return_err(cur, LITERAL, "invalid literal"); fail_comment: return_err(cur, INVALID_COMMENT, "unclosed multiline comment"); fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); fail_recursion: return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef val_incr #undef return_err } /** Read JSON document (accept all style, but optimized for pretty). */ static_inline yyjson_doc *read_root_pretty(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ err->msg = "unexpected end of data"; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ err->msg = _msg; \ } \ if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) #define val_incr() do { \ val++; \ if (unlikely(val >= val_end)) { \ usize alc_old = alc_len; \ alc_len += alc_len / 2; \ if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \ val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \ alc_old * sizeof(yyjson_val), \ alc_len * sizeof(yyjson_val)); \ if ((!val_tmp)) goto fail_alloc; \ val = val_tmp + (usize)(val - val_hdr); \ ctn = val_tmp + (usize)(ctn - val_hdr); \ val_hdr = val_tmp; \ val_end = val_tmp + (alc_len - 2); \ } \ } while (false) usize dat_len; /* data length in bytes, hint for allocator */ usize hdr_len; /* value count used by yyjson_doc */ usize alc_len; /* value count allocated */ usize alc_max; /* maximum value count for allocator */ usize ctn_len; /* the number of elements in current container */ yyjson_val *val_hdr; /* the head of allocated values */ yyjson_val *val_end; /* the end of allocated values */ yyjson_val *val_tmp; /* temporary pointer for realloc */ yyjson_val *val; /* current JSON value */ yyjson_val *ctn; /* current container */ yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ u32 container_depth = 0; /* limit on number of open array and map */ bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ dat_len = has_read_flag(STOP_WHEN_DONE) ? 256 : (usize)(end - cur); hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_max = USIZE_MAX / sizeof(yyjson_val); alc_len = hdr_len + (dat_len / YYJSON_READER_ESTIMATED_PRETTY_RATIO) + 4; alc_len = yyjson_min(alc_len, alc_max); val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_len * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val_end = val_hdr + (alc_len - 2); /* padding for key-value pair reading */ val = val_hdr + hdr_len; ctn = val; ctn_len = 0; raw = has_read_flag(NUMBER_AS_RAW) || has_read_flag(BIGNUM_AS_RAW); inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; if (*cur++ == '{') { ctn->tag = YYJSON_TYPE_OBJ; ctn->uni.ofs = 0; if (*cur == '\n') cur++; goto obj_key_begin; } else { ctn->tag = YYJSON_TYPE_ARR; ctn->uni.ofs = 0; if (*cur == '\n') cur++; goto arr_val_begin; } arr_begin: container_depth++; if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { goto fail_recursion; } /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); /* create a new array value, save parent container offset */ val_incr(); val->tag = YYJSON_TYPE_ARR; val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); /* push the new array value as current container */ ctn = val; ctn_len = 0; if (*cur == '\n') cur++; arr_val_begin: #if YYJSON_IS_REAL_GCC while (true) repeat16({ if (byte_match_2(cur, " ")) cur += 2; else break; }) #else while (true) repeat16({ if (likely(byte_match_2(cur, " "))) cur += 2; else break; }) #endif if (*cur == '{') { cur++; goto obj_begin; } if (*cur == '[') { cur++; goto arr_begin; } if (char_is_number(*cur)) { val_incr(); ctn_len++; if (likely(read_number(&cur, pre, flg, val, &msg))) goto arr_val_end; goto fail_number; } if (*cur == '"') { val_incr(); ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto arr_val_end; goto fail_string; } if (*cur == 't') { val_incr(); ctn_len++; if (likely(read_true(&cur, val))) goto arr_val_end; goto fail_literal; } if (*cur == 'f') { val_incr(); ctn_len++; if (likely(read_false(&cur, val))) goto arr_val_end; goto fail_literal; } if (*cur == 'n') { val_incr(); ctn_len++; if (likely(read_null(&cur, val))) goto arr_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_nan(false, &cur, pre, val)) goto arr_val_end; } goto fail_literal; } if (*cur == ']') { cur++; if (likely(ctn_len == 0)) goto arr_end; if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto arr_end; while (*cur != ',') cur--; goto fail_trailing_comma; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto arr_val_begin; } if (has_read_flag(ALLOW_INF_AND_NAN) && (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val_incr(); ctn_len++; if (read_inf_or_nan(false, &cur, pre, val)) goto arr_val_end; goto fail_character; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto arr_val_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; arr_val_end: if (byte_match_2(cur, ",\n")) { cur += 2; goto arr_val_begin; } if (*cur == ',') { cur++; goto arr_val_begin; } if (*cur == ']') { cur++; goto arr_end; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto arr_val_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto arr_val_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; arr_end: container_depth--; /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* save the next sibling value offset */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = ((ctn_len) << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; if (unlikely(ctn == ctn_parent)) goto doc_end; /* pop parent as current container */ ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); if (*cur == '\n') cur++; if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { goto obj_val_end; } else { goto arr_val_end; } obj_begin: container_depth++; if (unlikely(container_depth >= YYJSON_READER_CONTAINER_RECURSION_LIMIT)) { goto fail_recursion; } /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); val_incr(); val->tag = YYJSON_TYPE_OBJ; /* offset to the parent */ val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); ctn = val; ctn_len = 0; if (*cur == '\n') cur++; obj_key_begin: #if YYJSON_IS_REAL_GCC while (true) repeat16({ if (byte_match_2(cur, " ")) cur += 2; else break; }) #else while (true) repeat16({ if (likely(byte_match_2(cur, " "))) cur += 2; else break; }) #endif if (likely(*cur == '"')) { val_incr(); ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_key_end; goto fail_string; } if (likely(*cur == '}')) { cur++; if (likely(ctn_len == 0)) goto obj_end; if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto obj_end; while (*cur != ',') cur--; goto fail_trailing_comma; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_key_begin; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_key_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_key_end: if (byte_match_2(cur, ": ")) { cur += 2; goto obj_val_begin; } if (*cur == ':') { cur++; goto obj_val_begin; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_key_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_key_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_val_begin: if (*cur == '"') { val++; ctn_len++; if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_val_end; goto fail_string; } if (char_is_number(*cur)) { val++; ctn_len++; if (likely(read_number(&cur, pre, flg, val, &msg))) goto obj_val_end; goto fail_number; } if (*cur == '{') { cur++; goto obj_begin; } if (*cur == '[') { cur++; goto arr_begin; } if (*cur == 't') { val++; ctn_len++; if (likely(read_true(&cur, val))) goto obj_val_end; goto fail_literal; } if (*cur == 'f') { val++; ctn_len++; if (likely(read_false(&cur, val))) goto obj_val_end; goto fail_literal; } if (*cur == 'n') { val++; ctn_len++; if (likely(read_null(&cur, val))) goto obj_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { if (read_nan(false, &cur, pre, val)) goto obj_val_end; } goto fail_literal; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_val_begin; } if (has_read_flag(ALLOW_INF_AND_NAN) && (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val++; ctn_len++; if (read_inf_or_nan(false, &cur, pre, val)) goto obj_val_end; goto fail_character; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_val_begin; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_val_end: if (byte_match_2(cur, ",\n")) { cur += 2; goto obj_key_begin; } if (likely(*cur == ',')) { cur++; goto obj_key_begin; } if (likely(*cur == '}')) { cur++; goto obj_end; } if (char_is_space(*cur)) { while (char_is_space(*++cur)); goto obj_val_end; } if (has_read_flag(ALLOW_COMMENTS)) { if (skip_spaces_and_comments(&cur)) goto obj_val_end; if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character; obj_end: container_depth--; /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); /* point to the next value */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = (ctn_len << (YYJSON_TAG_BIT - 1)) | YYJSON_TYPE_OBJ; if (unlikely(ctn == ctn_parent)) goto doc_end; ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); if (*cur == '\n') cur++; if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { goto obj_val_end; } else { goto arr_val_end; } doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { if (has_read_flag(ALLOW_COMMENTS)) { skip_spaces_and_comments(&cur); if (byte_match_2(cur, "/*")) goto fail_comment; } else { while (char_is_space(*cur)) cur++; } if (unlikely(cur < end)) goto fail_garbage; } if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; doc->alc = alc; doc->dat_read = (usize)(cur - hdr); doc->val_read = (usize)((val - val_hdr)) - hdr_len + 1; doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; fail_string: return_err(cur, INVALID_STRING, msg); fail_number: return_err(cur, INVALID_NUMBER, msg); fail_alloc: return_err(cur, MEMORY_ALLOCATION, "memory allocation failed"); fail_trailing_comma: return_err(cur, JSON_STRUCTURE, "trailing comma is not allowed"); fail_literal: return_err(cur, LITERAL, "invalid literal"); fail_comment: return_err(cur, INVALID_COMMENT, "unclosed multiline comment"); fail_character: return_err(cur, UNEXPECTED_CHARACTER, "unexpected character"); fail_garbage: return_err(cur, UNEXPECTED_CONTENT, "unexpected content after document"); fail_recursion: return_err(cur, RECURSION_DEPTH, "array and object recursion depth exceeded"); #undef val_incr #undef return_err } /*============================================================================== * JSON Reader Entrance *============================================================================*/ yyjson_doc *yyjson_read_opts(char *dat, usize len, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err) { #define return_err(_pos, _code, _msg) do { \ err->pos = (usize)(_pos); \ err->msg = _msg; \ err->code = YYJSON_READ_ERROR_##_code; \ if (!has_read_flag(INSITU) && hdr) alc.free(alc.ctx, (void *)hdr); \ return NULL; \ } while (false) yyjson_alc alc; yyjson_doc *doc; u8 *hdr = NULL, *end, *cur; /* validate input parameters */ if (!alc_ptr) { alc = YYJSON_DEFAULT_ALC; } else { alc = *alc_ptr; } if (unlikely(!dat)) { return_err(0, INVALID_PARAMETER, "input data is NULL"); } if (unlikely(!len)) { return_err(0, INVALID_PARAMETER, "input length is 0"); } /* add 4-byte zero padding for input data if necessary */ if (has_read_flag(INSITU)) { hdr = (u8 *)dat; end = (u8 *)dat + len; cur = (u8 *)dat; } else { if (unlikely(len >= USIZE_MAX - YYJSON_PADDING_SIZE)) { return_err(0, MEMORY_ALLOCATION, "memory allocation failed"); } hdr = (u8 *)alc.malloc(alc.ctx, len + YYJSON_PADDING_SIZE); if (unlikely(!hdr)) { return_err(0, MEMORY_ALLOCATION, "memory allocation failed"); } end = hdr + len; cur = hdr; memcpy(hdr, dat, len); memset(end, 0, YYJSON_PADDING_SIZE); } /* skip empty contents before json document */ if (unlikely(char_is_space_or_comment(*cur))) { if (has_read_flag(ALLOW_COMMENTS)) { if (!skip_spaces_and_comments(&cur)) { return_err(cur - hdr, INVALID_COMMENT, "unclosed multiline comment"); } } else { if (likely(char_is_space(*cur))) { while (char_is_space(*++cur)); } } if (unlikely(cur >= end)) { return_err(0, EMPTY_CONTENT, "input data is empty"); } } /* read json document */ if (likely(char_is_container(*cur))) { if (char_is_space(cur[1]) && char_is_space(cur[2])) { doc = read_root_pretty(hdr, cur, end, alc, flg, err); } else { doc = read_root_minify(hdr, cur, end, alc, flg, err); } } else { doc = read_root_single(hdr, cur, end, alc, flg, err); } /* check result */ if (likely(doc)) { memset(err, 0, sizeof(yyjson_read_err)); } else { /* RFC 8259: JSON text MUST be encoded using UTF-8 */ if (err->pos == 0 && err->code != YYJSON_READ_ERROR_MEMORY_ALLOCATION) { if ((hdr[0] == 0xEF && hdr[1] == 0xBB && hdr[2] == 0xBF)) { err->msg = "byte order mark (BOM) is not supported"; } else if (len >= 4 && ((hdr[0] == 0x00 && hdr[1] == 0x00 && hdr[2] == 0xFE && hdr[3] == 0xFF) || (hdr[0] == 0xFF && hdr[1] == 0xFE && hdr[2] == 0x00 && hdr[3] == 0x00))) { err->msg = "UTF-32 encoding is not supported"; } else if (len >= 2 && ((hdr[0] == 0xFE && hdr[1] == 0xFF) || (hdr[0] == 0xFF && hdr[1] == 0xFE))) { err->msg = "UTF-16 encoding is not supported"; } } if (!has_read_flag(INSITU)) alc.free(alc.ctx, (void *)hdr); } return doc; #undef return_err } yyjson_doc *yyjson_read_file(const char *path, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err) { #define return_err(_code, _msg) do { \ err->pos = 0; \ err->msg = _msg; \ err->code = YYJSON_READ_ERROR_##_code; \ return NULL; \ } while (false) yyjson_doc *doc; FILE *file; if (unlikely(!path)) return_err(INVALID_PARAMETER, "input path is NULL"); file = fopen_readonly(path); if (unlikely(!file)) return_err(FILE_OPEN, "file opening failed"); doc = yyjson_read_fp(file, flg, alc_ptr, err); fclose(file); return doc; #undef return_err } yyjson_doc *yyjson_read_fp(FILE *file, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err) { #define return_err(_code, _msg) do { \ err->pos = 0; \ err->msg = _msg; \ err->code = YYJSON_READ_ERROR_##_code; \ if (buf) alc.free(alc.ctx, buf); \ return NULL; \ } while (false) yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_doc *doc; long file_size = 0, file_pos; void *buf = NULL; usize buf_size = 0; /* validate input parameters */ if (unlikely(!file)) return_err(INVALID_PARAMETER, "input file is NULL"); /* get current position */ file_pos = ftell(file); if (file_pos != -1) { /* get total file size, may fail */ if (fseek(file, 0, SEEK_END) == 0) file_size = ftell(file); /* reset to original position, may fail */ if (fseek(file, file_pos, SEEK_SET) != 0) file_size = 0; /* get file size from current postion to end */ if (file_size > 0) file_size -= file_pos; } /* read file */ if (file_size > 0) { /* read the entire file in one call */ buf_size = (usize)file_size + YYJSON_PADDING_SIZE; buf = alc.malloc(alc.ctx, buf_size); if (buf == NULL) { return_err(MEMORY_ALLOCATION, "fail to alloc memory"); } if (fread_safe(buf, (usize)file_size, file) != (usize)file_size) { return_err(FILE_READ, "file reading failed"); } } else { /* failed to get file size, read it as a stream */ usize chunk_min = (usize)64; usize chunk_max = (usize)512 * 1024 * 1024; usize chunk_now = chunk_min; usize read_size; void *tmp; buf_size = YYJSON_PADDING_SIZE; while (true) { if (buf_size + chunk_now < buf_size) { /* overflow */ return_err(MEMORY_ALLOCATION, "fail to alloc memory"); } buf_size += chunk_now; if (!buf) { buf = alc.malloc(alc.ctx, buf_size); if (!buf) return_err(MEMORY_ALLOCATION, "fail to alloc memory"); } else { tmp = alc.realloc(alc.ctx, buf, buf_size - chunk_now, buf_size); if (!tmp) return_err(MEMORY_ALLOCATION, "fail to alloc memory"); buf = tmp; } tmp = ((u8 *)buf) + buf_size - YYJSON_PADDING_SIZE - chunk_now; read_size = fread_safe(tmp, chunk_now, file); file_size += (long)read_size; if (read_size != chunk_now) break; chunk_now *= 2; if (chunk_now > chunk_max) chunk_now = chunk_max; } } /* read JSON */ memset((u8 *)buf + file_size, 0, YYJSON_PADDING_SIZE); flg |= YYJSON_READ_INSITU; doc = yyjson_read_opts((char *)buf, (usize)file_size, flg, &alc, err); if (doc) { doc->str_pool = (char *)buf; return doc; } else { alc.free(alc.ctx, buf); return NULL; } #undef return_err } const char *yyjson_read_number(const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err) { #define return_err(_pos, _code, _msg) do { \ err->pos = _pos > hdr ? (usize)(_pos - hdr) : 0; \ err->msg = _msg; \ err->code = YYJSON_READ_ERROR_##_code; \ return NULL; \ } while (false) u8 *hdr = constcast(u8 *)dat, *cur = hdr; bool raw; /* read number as raw */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ const char *msg; #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV u8 buf[128]; usize dat_len; #endif if (unlikely(!dat)) { return_err(cur, INVALID_PARAMETER, "input data is NULL"); } if (unlikely(!val)) { return_err(cur, INVALID_PARAMETER, "output value is NULL"); } #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV if (!alc) alc = &YYJSON_DEFAULT_ALC; dat_len = strlen(dat); if (dat_len < sizeof(buf)) { memcpy(buf, dat, dat_len + 1); hdr = buf; cur = hdr; } else { hdr = (u8 *)alc->malloc(alc->ctx, dat_len + 1); cur = hdr; if (unlikely(!hdr)) { return_err(cur, MEMORY_ALLOCATION, "memory allocation failed"); } memcpy(hdr, dat, dat_len + 1); } hdr[dat_len] = 0; #endif raw = false; raw_end = NULL; pre = raw ? &raw_end : NULL; #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV if (!read_number(&cur, pre, flg, val, &msg)) { if (dat_len >= sizeof(buf)) alc->free(alc->ctx, hdr); return_err(cur, INVALID_NUMBER, msg); } if (dat_len >= sizeof(buf)) alc->free(alc->ctx, hdr); if (yyjson_is_raw(val)) val->uni.str = dat; return dat + (cur - hdr); #else if (!read_number(&cur, pre, flg, val, &msg)) { return_err(cur, INVALID_NUMBER, msg); } return (const char *)cur; #endif #undef return_err } #endif /* YYJSON_DISABLE_READER */ #if !YYJSON_DISABLE_WRITER /*============================================================================== * Integer Writer * * The maximum value of uint32_t is 4294967295 (10 digits), * these digits are named as 'aabbccddee' here. * * Although most compilers may convert the "division by constant value" into * "multiply and shift", manual conversion can still help some compilers * generate fewer and better instructions. * * Reference: * Division by Invariant Integers using Multiplication, 1994. * https://gmplib.org/~tege/divcnst-pldi94.pdf * Improved division by invariant integers, 2011. * https://gmplib.org/~tege/division-paper.pdf *============================================================================*/ /** Digit table from 00 to 99. */ yyjson_align(2) static const char digit_table[200] = { '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9' }; static_inline u8 *write_u32_len_8(u32 val, u8 *buf) { u32 aa, bb, cc, dd, aabb, ccdd; /* 8 digits: aabbccdd */ aabb = (u32)(((u64)val * 109951163) >> 40); /* (val / 10000) */ ccdd = val - aabb * 10000; /* (val % 10000) */ aa = (aabb * 5243) >> 19; /* (aabb / 100) */ cc = (ccdd * 5243) >> 19; /* (ccdd / 100) */ bb = aabb - aa * 100; /* (aabb % 100) */ dd = ccdd - cc * 100; /* (ccdd % 100) */ byte_copy_2(buf + 0, digit_table + aa * 2); byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); byte_copy_2(buf + 6, digit_table + dd * 2); return buf + 8; } static_inline u8 *write_u32_len_4(u32 val, u8 *buf) { u32 aa, bb; /* 4 digits: aabb */ aa = (val * 5243) >> 19; /* (val / 100) */ bb = val - aa * 100; /* (val % 100) */ byte_copy_2(buf + 0, digit_table + aa * 2); byte_copy_2(buf + 2, digit_table + bb * 2); return buf + 4; } static_inline u8 *write_u32_len_1_8(u32 val, u8 *buf) { u32 aa, bb, cc, dd, aabb, bbcc, ccdd, lz; if (val < 100) { /* 1-2 digits: aa */ lz = val < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + val * 2 + lz); buf -= lz; return buf + 2; } else if (val < 10000) { /* 3-4 digits: aabb */ aa = (val * 5243) >> 19; /* (val / 100) */ bb = val - aa * 100; /* (val % 100) */ lz = aa < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + aa * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); return buf + 4; } else if (val < 1000000) { /* 5-6 digits: aabbcc */ aa = (u32)(((u64)val * 429497) >> 32); /* (val / 10000) */ bbcc = val - aa * 10000; /* (val % 10000) */ bb = (bbcc * 5243) >> 19; /* (bbcc / 100) */ cc = bbcc - bb * 100; /* (bbcc % 100) */ lz = aa < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + aa * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); return buf + 6; } else { /* 7-8 digits: aabbccdd */ aabb = (u32)(((u64)val * 109951163) >> 40); /* (val / 10000) */ ccdd = val - aabb * 10000; /* (val % 10000) */ aa = (aabb * 5243) >> 19; /* (aabb / 100) */ cc = (ccdd * 5243) >> 19; /* (ccdd / 100) */ bb = aabb - aa * 100; /* (aabb % 100) */ dd = ccdd - cc * 100; /* (ccdd % 100) */ lz = aa < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + aa * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); byte_copy_2(buf + 6, digit_table + dd * 2); return buf + 8; } } static_inline u8 *write_u64_len_5_8(u32 val, u8 *buf) { u32 aa, bb, cc, dd, aabb, bbcc, ccdd, lz; if (val < 1000000) { /* 5-6 digits: aabbcc */ aa = (u32)(((u64)val * 429497) >> 32); /* (val / 10000) */ bbcc = val - aa * 10000; /* (val % 10000) */ bb = (bbcc * 5243) >> 19; /* (bbcc / 100) */ cc = bbcc - bb * 100; /* (bbcc % 100) */ lz = aa < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + aa * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); return buf + 6; } else { /* 7-8 digits: aabbccdd */ aabb = (u32)(((u64)val * 109951163) >> 40); /* (val / 10000) */ ccdd = val - aabb * 10000; /* (val % 10000) */ aa = (aabb * 5243) >> 19; /* (aabb / 100) */ cc = (ccdd * 5243) >> 19; /* (ccdd / 100) */ bb = aabb - aa * 100; /* (aabb % 100) */ dd = ccdd - cc * 100; /* (ccdd % 100) */ lz = aa < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + aa * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); byte_copy_2(buf + 6, digit_table + dd * 2); return buf + 8; } } static_inline u8 *write_u64(u64 val, u8 *buf) { u64 tmp, hgh; u32 mid, low; if (val < 100000000) { /* 1-8 digits */ buf = write_u32_len_1_8((u32)val, buf); return buf; } else if (val < (u64)100000000 * 100000000) { /* 9-16 digits */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ buf = write_u32_len_1_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; } else { /* 17-20 digits */ tmp = val / 100000000; /* (val / 100000000) */ low = (u32)(val - tmp * 100000000); /* (val % 100000000) */ hgh = (u32)(tmp / 10000); /* (tmp / 10000) */ mid = (u32)(tmp - hgh * 10000); /* (tmp % 10000) */ buf = write_u64_len_5_8((u32)hgh, buf); buf = write_u32_len_4(mid, buf); buf = write_u32_len_8(low, buf); return buf; } } /*============================================================================== * Number Writer *============================================================================*/ #if YYJSON_HAS_IEEE_754 && !YYJSON_DISABLE_FAST_FP_CONV /* FP_WRITER */ /** Trailing zero count table for number 0 to 99. (generate with misc/make_tables.c) */ static const u8 dec_trailing_zero_table[] = { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /** Write an unsigned integer with a length of 1 to 16. */ static_inline u8 *write_u64_len_1_to_16(u64 val, u8 *buf) { u64 hgh; u32 low; if (val < 100000000) { /* 1-8 digits */ buf = write_u32_len_1_8((u32)val, buf); return buf; } else { /* 9-16 digits */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ buf = write_u32_len_1_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; } } /** Write an unsigned integer with a length of 1 to 17. */ static_inline u8 *write_u64_len_1_to_17(u64 val, u8 *buf) { u64 hgh; u32 mid, low, one; if (val >= (u64)100000000 * 10000000) { /* len: 16 to 17 */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ one = (u32)(hgh / 100000000); /* (hgh / 100000000) */ mid = (u32)(hgh - (u64)one * 100000000); /* (hgh % 100000000) */ *buf = (u8)((u8)one + (u8)'0'); buf += one > 0; buf = write_u32_len_8(mid, buf); buf = write_u32_len_8(low, buf); return buf; } else if (val >= (u64)100000000){ /* len: 9 to 15 */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ buf = write_u32_len_1_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; } else { /* len: 1 to 8 */ buf = write_u32_len_1_8((u32)val, buf); return buf; } } /** Write an unsigned integer with a length of 15 to 17 with trailing zero trimmed. These digits are named as "aabbccddeeffgghhii" here. For example, input 1234567890123000, output "1234567890123". */ static_inline u8 *write_u64_len_15_to_17_trim(u8 *buf, u64 sig) { bool lz; /* leading zero */ u32 tz1, tz2, tz; /* trailing zero */ u32 abbccddee = (u32)(sig / 100000000); u32 ffgghhii = (u32)(sig - (u64)abbccddee * 100000000); u32 abbcc = abbccddee / 10000; /* (abbccddee / 10000) */ u32 ddee = abbccddee - abbcc * 10000; /* (abbccddee % 10000) */ u32 abb = (u32)(((u64)abbcc * 167773) >> 24); /* (abbcc / 100) */ u32 a = (abb * 41) >> 12; /* (abb / 100) */ u32 bb = abb - a * 100; /* (abb % 100) */ u32 cc = abbcc - abb * 100; /* (abbcc % 100) */ /* write abbcc */ buf[0] = (u8)(a + '0'); buf += a > 0; lz = bb < 10 && a == 0; byte_copy_2(buf + 0, digit_table + bb * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + cc * 2); if (ffgghhii) { u32 dd = (ddee * 5243) >> 19; /* (ddee / 100) */ u32 ee = ddee - dd * 100; /* (ddee % 100) */ u32 ffgg = (u32)(((u64)ffgghhii * 109951163) >> 40); /* (val / 10000) */ u32 hhii = ffgghhii - ffgg * 10000; /* (val % 10000) */ u32 ff = (ffgg * 5243) >> 19; /* (aabb / 100) */ u32 gg = ffgg - ff * 100; /* (aabb % 100) */ byte_copy_2(buf + 4, digit_table + dd * 2); byte_copy_2(buf + 6, digit_table + ee * 2); byte_copy_2(buf + 8, digit_table + ff * 2); byte_copy_2(buf + 10, digit_table + gg * 2); if (hhii) { u32 hh = (hhii * 5243) >> 19; /* (ccdd / 100) */ u32 ii = hhii - hh * 100; /* (ccdd % 100) */ byte_copy_2(buf + 12, digit_table + hh * 2); byte_copy_2(buf + 14, digit_table + ii * 2); tz1 = dec_trailing_zero_table[hh]; tz2 = dec_trailing_zero_table[ii]; tz = ii ? tz2 : (tz1 + 2); buf += 16 - tz; return buf; } else { tz1 = dec_trailing_zero_table[ff]; tz2 = dec_trailing_zero_table[gg]; tz = gg ? tz2 : (tz1 + 2); buf += 12 - tz; return buf; } } else { if (ddee) { u32 dd = (ddee * 5243) >> 19; /* (ddee / 100) */ u32 ee = ddee - dd * 100; /* (ddee % 100) */ byte_copy_2(buf + 4, digit_table + dd * 2); byte_copy_2(buf + 6, digit_table + ee * 2); tz1 = dec_trailing_zero_table[dd]; tz2 = dec_trailing_zero_table[ee]; tz = ee ? tz2 : (tz1 + 2); buf += 8 - tz; return buf; } else { tz1 = dec_trailing_zero_table[bb]; tz2 = dec_trailing_zero_table[cc]; tz = cc ? tz2 : (tz1 + tz2); buf += 4 - tz; return buf; } } } /** Write a signed integer in the range -324 to 308. */ static_inline u8 *write_f64_exp(i32 exp, u8 *buf) { buf[0] = '-'; buf += exp < 0; exp = exp < 0 ? -exp : exp; if (exp < 100) { u32 lz = exp < 10; byte_copy_2(buf + 0, digit_table + (u32)exp * 2 + lz); return buf + 2 - lz; } else { u32 hi = ((u32)exp * 656) >> 16; /* exp / 100 */ u32 lo = (u32)exp - hi * 100; /* exp % 100 */ buf[0] = (u8)((u8)hi + (u8)'0'); byte_copy_2(buf + 1, digit_table + lo * 2); return buf + 3; } } /** Multiplies 128-bit integer and returns highest 64-bit rounded value. */ static_inline u64 round_to_odd(u64 hi, u64 lo, u64 cp) { u64 x_hi, x_lo, y_hi, y_lo; u128_mul(cp, lo, &x_hi, &x_lo); u128_mul_add(cp, hi, x_hi, &y_hi, &y_lo); return y_hi | (y_lo > 1); } /** Convert double number from binary to decimal. The output significand is shortest decimal but may have trailing zeros. This function use the Schubfach algorithm: Raffaello Giulietti, The Schubfach way to render doubles (5th version), 2022. https://drive.google.com/file/d/1gp5xv4CAa78SVgCeWfGqqI4FfYYYuNFb https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-November/083536.html https://github.com/openjdk/jdk/pull/3402 (Java implementation) https://github.com/abolz/Drachennest (C++ implementation) See also: Dragonbox: A New Floating-Point Binary-to-Decimal Conversion Algorithm, 2022. https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf https://github.com/jk-jeon/dragonbox @param sig_raw The raw value of significand in IEEE 754 format. @param exp_raw The raw value of exponent in IEEE 754 format. @param sig_bin The decoded value of significand in binary. @param exp_bin The decoded value of exponent in binary. @param sig_dec The output value of significand in decimal. @param exp_dec The output value of exponent in decimal. @warning The input double number should not be 0, inf, nan. */ static_inline void f64_bin_to_dec(u64 sig_raw, u32 exp_raw, u64 sig_bin, i32 exp_bin, u64 *sig_dec, i32 *exp_dec) { bool is_even, regular_spacing, u_inside, w_inside, round_up; u64 s, sp, cb, cbl, cbr, vb, vbl, vbr, pow10hi, pow10lo, upper, lower, mid; i32 k, h, exp10; is_even = !(sig_bin & 1); regular_spacing = (sig_raw == 0 && exp_raw > 1); cbl = 4 * sig_bin - 2 + regular_spacing; cb = 4 * sig_bin; cbr = 4 * sig_bin + 2; /* exp_bin: [-1074, 971] */ /* k = regular_spacing ? floor(log10(pow(2, exp_bin))) */ /* : floor(log10(pow(2, exp_bin) * 3.0 / 4.0)) */ /* = regular_spacing ? floor(exp_bin * log10(2)) */ /* : floor(exp_bin * log10(2) + log10(3.0 / 4.0)) */ k = (i32)(exp_bin * 315653 - (regular_spacing ? 131237 : 0)) >> 20; /* k: [-324, 292] */ /* h = exp_bin + floor(log2(pow(10, e))) */ /* = exp_bin + floor(log2(10) * e) */ exp10 = -k; h = exp_bin + ((exp10 * 217707) >> 16) + 1; pow10_table_get_sig(exp10, &pow10hi, &pow10lo); pow10lo += (exp10 < POW10_SIG_TABLE_MIN_EXACT_EXP || exp10 > POW10_SIG_TABLE_MAX_EXACT_EXP); vbl = round_to_odd(pow10hi, pow10lo, cbl << h); vb = round_to_odd(pow10hi, pow10lo, cb << h); vbr = round_to_odd(pow10hi, pow10lo, cbr << h); lower = vbl + !is_even; upper = vbr - !is_even; s = vb / 4; if (s >= 10) { sp = s / 10; u_inside = (lower <= 40 * sp); w_inside = (upper >= 40 * sp + 40); if (u_inside != w_inside) { *sig_dec = sp + w_inside; *exp_dec = k + 1; return; } } u_inside = (lower <= 4 * s); w_inside = (upper >= 4 * s + 4); mid = 4 * s + 2; round_up = (vb > mid) || (vb == mid && (s & 1) != 0); *sig_dec = s + ((u_inside != w_inside) ? w_inside : round_up); *exp_dec = k; } /** Write a double number (requires 32 bytes buffer). We follows the ECMAScript specification to print floating point numbers, but with the following changes: 1. Keep the negative sign of 0.0 to preserve input information. 2. Keep decimal point to indicate the number is floating point. 3. Remove positive sign of exponent part. */ static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { u64 sig_bin, sig_dec, sig_raw; i32 exp_bin, exp_dec, sig_len, dot_pos, i, max; u32 exp_raw, hi, lo; u8 *hdr, *num_hdr, *num_end, *dot_end; bool sign; /* decode raw bytes from IEEE-754 double format. */ sign = (bool)(raw >> (F64_BITS - 1)); sig_raw = raw & F64_SIG_MASK; exp_raw = (u32)((raw & F64_EXP_MASK) >> F64_SIG_BITS); /* return inf and nan */ if (unlikely(exp_raw == ((u32)1 << F64_EXP_BITS) - 1)) { if (has_write_flag(INF_AND_NAN_AS_NULL)) { byte_copy_4(buf, "null"); return buf + 4; } else if (has_write_flag(ALLOW_INF_AND_NAN)) { if (sig_raw == 0) { buf[0] = '-'; buf += sign; byte_copy_8(buf, "Infinity"); buf += 8; return buf; } else { byte_copy_4(buf, "NaN"); return buf + 3; } } return NULL; } /* add sign for all finite double value, including 0.0 and inf */ buf[0] = '-'; buf += sign; hdr = buf; /* return zero */ if ((raw << 1) == 0) { byte_copy_4(buf, "0.0"); buf += 3; return buf; } if (likely(exp_raw != 0)) { /* normal number */ sig_bin = sig_raw | ((u64)1 << F64_SIG_BITS); exp_bin = (i32)exp_raw - F64_EXP_BIAS - F64_SIG_BITS; /* fast path for small integer number without fraction */ if (-F64_SIG_BITS <= exp_bin && exp_bin <= 0) { if (u64_tz_bits(sig_bin) >= (u32)-exp_bin) { /* number is integer in range 1 to 0x1FFFFFFFFFFFFF */ sig_dec = sig_bin >> -exp_bin; buf = write_u64_len_1_to_16(sig_dec, buf); byte_copy_2(buf, ".0"); buf += 2; return buf; } } /* binary to decimal */ f64_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); /* the sig length is 15 to 17 */ sig_len = 17; sig_len -= (sig_dec < (u64)100000000 * 100000000); sig_len -= (sig_dec < (u64)100000000 * 10000000); /* the decimal point position relative to the first digit */ dot_pos = sig_len + exp_dec; if (-6 < dot_pos && dot_pos <= 21) { /* no need to write exponent part */ if (dot_pos <= 0) { /* dot before first digit */ /* such as 0.1234, 0.000001234 */ num_hdr = hdr + (2 - dot_pos); num_end = write_u64_len_15_to_17_trim(num_hdr, sig_dec); hdr[0] = '0'; hdr[1] = '.'; hdr += 2; max = -dot_pos; for (i = 0; i < max; i++) hdr[i] = '0'; return num_end; } else { /* dot after first digit */ /* such as 1.234, 1234.0, 123400000000000000000.0 */ memset(hdr + 0, '0', 8); memset(hdr + 8, '0', 8); memset(hdr + 16, '0', 8); num_hdr = hdr + 1; num_end = write_u64_len_15_to_17_trim(num_hdr, sig_dec); for (i = 0; i < dot_pos; i++) hdr[i] = hdr[i + 1]; hdr[dot_pos] = '.'; dot_end = hdr + dot_pos + 2; return dot_end < num_end ? num_end : dot_end; } } else { /* write with scientific notation */ /* such as 1.234e56 */ u8 *end = write_u64_len_15_to_17_trim(buf + 1, sig_dec); end -= (end == buf + 2); /* remove '.0', e.g. 2.0e34 -> 2e34 */ exp_dec += sig_len - 1; hdr[0] = hdr[1]; hdr[1] = '.'; end[0] = 'e'; buf = write_f64_exp(exp_dec, end + 1); return buf; } } else { /* subnormal number */ sig_bin = sig_raw; exp_bin = 1 - F64_EXP_BIAS - F64_SIG_BITS; /* binary to decimal */ f64_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); /* write significand part */ buf = write_u64_len_1_to_17(sig_dec, buf + 1); hdr[0] = hdr[1]; hdr[1] = '.'; do { buf--; exp_dec++; } while (*buf == '0'); exp_dec += (i32)(buf - hdr - 2); buf += (*buf != '.'); buf[0] = 'e'; buf++; /* write exponent part */ buf[0] = '-'; buf++; exp_dec = -exp_dec; hi = ((u32)exp_dec * 656) >> 16; /* exp / 100 */ lo = (u32)exp_dec - hi * 100; /* exp % 100 */ buf[0] = (u8)((u8)hi + (u8)'0'); byte_copy_2(buf + 1, digit_table + lo * 2); buf += 3; return buf; } } #else /* FP_WRITER */ /** Write a double number (requires 32 bytes buffer). */ static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { /* For IEEE 754, `DBL_DECIMAL_DIG` is 17 for round-trip. For non-IEEE formats, 17 is used to avoid buffer overflow, round-trip is not guaranteed. */ #if defined(DBL_DECIMAL_DIG) && DBL_DECIMAL_DIG != 17 int dig = DBL_DECIMAL_DIG > 17 ? 17 : DBL_DECIMAL_DIG; #else int dig = 17; #endif /* The snprintf() function is locale-dependent. For currently known locales, (en, zh, ja, ko, am, he, hi) use '.' as the decimal point, while other locales use ',' as the decimal point. we need to replace ',' with '.' to avoid the locale setting. */ f64 val = f64_from_raw(raw); #if YYJSON_MSC_VER >= 1400 int len = sprintf_s((char *)buf, 32, "%.*g", dig, val); #elif defined(snprintf) || (YYJSON_STDC_VER >= 199901L) int len = snprintf((char *)buf, 32, "%.*g", dig, val); #else int len = sprintf((char *)buf, "%.*g", dig, val); #endif u8 *cur = buf; if (unlikely(len < 1)) return NULL; cur += (*cur == '-'); if (unlikely(!digi_is_digit(*cur))) { /* nan, inf, or bad output */ if (has_write_flag(INF_AND_NAN_AS_NULL)) { byte_copy_4(buf, "null"); return buf + 4; } else if (has_write_flag(ALLOW_INF_AND_NAN)) { if (*cur == 'i') { byte_copy_8(cur, "Infinity"); cur += 8; return cur; } else if (*cur == 'n') { byte_copy_4(buf, "NaN"); return buf + 3; } } return NULL; } else { /* finite number */ int i = 0; bool fp = false; for (; i < len; i++) { if (buf[i] == ',') buf[i] = '.'; if (digi_is_fp((u8)buf[i])) fp = true; } if (!fp) { buf[len++] = '.'; buf[len++] = '0'; } } return buf + len; } #endif /* FP_WRITER */ /** Write a JSON number (requires 32 bytes buffer). */ static_inline u8 *write_number(u8 *cur, yyjson_val *val, yyjson_write_flag flg) { if (val->tag & YYJSON_SUBTYPE_REAL) { u64 raw = val->uni.u64; return write_f64_raw(cur, raw, flg); } else { u64 pos = val->uni.u64; u64 neg = ~pos + 1; usize sgn = ((val->tag & YYJSON_SUBTYPE_SINT) > 0) & ((i64)pos < 0); *cur = '-'; return write_u64(sgn ? neg : pos, cur + sgn); } } /*============================================================================== * String Writer *============================================================================*/ /** Character encode type, if (type > CHAR_ENC_ERR_1) bytes = type / 2; */ typedef u8 char_enc_type; #define CHAR_ENC_CPY_1 0 /* 1-byte UTF-8, copy. */ #define CHAR_ENC_ERR_1 1 /* 1-byte UTF-8, error. */ #define CHAR_ENC_ESC_A 2 /* 1-byte ASCII, escaped as '\x'. */ #define CHAR_ENC_ESC_1 3 /* 1-byte UTF-8, escaped as '\uXXXX'. */ #define CHAR_ENC_CPY_2 4 /* 2-byte UTF-8, copy. */ #define CHAR_ENC_ESC_2 5 /* 2-byte UTF-8, escaped as '\uXXXX'. */ #define CHAR_ENC_CPY_3 6 /* 3-byte UTF-8, copy. */ #define CHAR_ENC_ESC_3 7 /* 3-byte UTF-8, escaped as '\uXXXX'. */ #define CHAR_ENC_CPY_4 8 /* 4-byte UTF-8, copy. */ #define CHAR_ENC_ESC_4 9 /* 4-byte UTF-8, escaped as '\uXXXX\uXXXX'. */ /** Character encode type table: don't escape unicode, don't escape '/'. (generate with misc/make_tables.c) */ static const char_enc_type enc_table_cpy[256] = { 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 1, 1, 1, 1, 1, 1, 1 }; /** Escaped hex character table: ["00" "01" "02" ... "FD" "FE" "FF"]. (generate with misc/make_tables.c) */ yyjson_align(2) static const u8 esc_hex_char_table[512] = { '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'A', '0', 'B', '0', 'C', '0', 'D', '0', 'E', '0', 'F', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '1', 'A', '1', 'B', '1', 'C', '1', 'D', '1', 'E', '1', 'F', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'A', '2', 'B', '2', 'C', '2', 'D', '2', 'E', '2', 'F', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '3', 'A', '3', 'B', '3', 'C', '3', 'D', '3', 'E', '3', 'F', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'A', '4', 'B', '4', 'C', '4', 'D', '4', 'E', '4', 'F', '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'A', '5', 'B', '5', 'C', '5', 'D', '5', 'E', '5', 'F', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '6', 'A', '6', 'B', '6', 'C', '6', 'D', '6', 'E', '6', 'F', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'A', '7', 'B', '7', 'C', '7', 'D', '7', 'E', '7', 'F', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '8', 'A', '8', 'B', '8', 'C', '8', 'D', '8', 'E', '8', 'F', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'A', '9', 'B', '9', 'C', '9', 'D', '9', 'E', '9', 'F', 'A', '0', 'A', '1', 'A', '2', 'A', '3', 'A', '4', 'A', '5', 'A', '6', 'A', '7', 'A', '8', 'A', '9', 'A', 'A', 'A', 'B', 'A', 'C', 'A', 'D', 'A', 'E', 'A', 'F', 'B', '0', 'B', '1', 'B', '2', 'B', '3', 'B', '4', 'B', '5', 'B', '6', 'B', '7', 'B', '8', 'B', '9', 'B', 'A', 'B', 'B', 'B', 'C', 'B', 'D', 'B', 'E', 'B', 'F', 'C', '0', 'C', '1', 'C', '2', 'C', '3', 'C', '4', 'C', '5', 'C', '6', 'C', '7', 'C', '8', 'C', '9', 'C', 'A', 'C', 'B', 'C', 'C', 'C', 'D', 'C', 'E', 'C', 'F', 'D', '0', 'D', '1', 'D', '2', 'D', '3', 'D', '4', 'D', '5', 'D', '6', 'D', '7', 'D', '8', 'D', '9', 'D', 'A', 'D', 'B', 'D', 'C', 'D', 'D', 'D', 'E', 'D', 'F', 'E', '0', 'E', '1', 'E', '2', 'E', '3', 'E', '4', 'E', '5', 'E', '6', 'E', '7', 'E', '8', 'E', '9', 'E', 'A', 'E', 'B', 'E', 'C', 'E', 'D', 'E', 'E', 'E', 'F', 'F', '0', 'F', '1', 'F', '2', 'F', '3', 'F', '4', 'F', '5', 'F', '6', 'F', '7', 'F', '8', 'F', '9', 'F', 'A', 'F', 'B', 'F', 'C', 'F', 'D', 'F', 'E', 'F', 'F' }; /** Escaped single character table. (generate with misc/make_tables.c) */ yyjson_align(2) static const u8 esc_single_char_table[512] = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\\', 'b', '\\', 't', '\\', 'n', ' ', ' ', '\\', 'f', '\\', 'r', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\\', '"', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\\', '/', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\\', '\\', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }; /** Returns the encode table with options. */ static_inline const char_enc_type *get_enc_table_with_flag( yyjson_read_flag flg) { if (has_write_flag(ESCAPE_UNICODE)) { if (has_write_flag(ESCAPE_SLASHES)) { return enc_table_esc_slash; } else { return enc_table_esc; } } else { if (has_write_flag(ESCAPE_SLASHES)) { return enc_table_cpy_slash; } else { return enc_table_cpy; } } } /** Write raw string. */ static_inline u8 *write_raw(u8 *cur, const u8 *raw, usize raw_len) { memcpy(cur, raw, raw_len); return cur + raw_len; } /** Write string no-escape. @param cur Buffer cursor. @param str A UTF-8 string, null-terminator is not required. @param str_len Length of string in bytes. @return The buffer cursor after string. */ static_inline u8 *write_string_noesc(u8 *cur, const u8 *str, usize str_len) { *cur++ = '"'; while (str_len >= 16) { byte_copy_16(cur, str); cur += 16; str += 16; str_len -= 16; } while (str_len >= 4) { byte_copy_4(cur, str); cur += 4; str += 4; str_len -= 4; } while (str_len) { *cur++ = *str++; str_len -= 1; } *cur++ = '"'; return cur; } /** Write UTF-8 string (requires len * 6 + 2 bytes buffer). @param cur Buffer cursor. @param esc Escape unicode. @param inv Allow invalid unicode. @param str A UTF-8 string, null-terminator is not required. @param str_len Length of string in bytes. @param enc_table Encode type table for character. @return The buffer cursor after string, or NULL on invalid unicode. */ static_inline u8 *write_string(u8 *cur, bool esc, bool inv, const u8 *str, usize str_len, const char_enc_type *enc_table) { /* UTF-8 character mask and pattern, see `read_string()` for details. */ #if YYJSON_ENDIAN == YYJSON_BIG_ENDIAN const u16 b2_mask = 0xE0C0UL; const u16 b2_patt = 0xC080UL; const u16 b2_requ = 0x1E00UL; const u32 b3_mask = 0xF0C0C000UL; const u32 b3_patt = 0xE0808000UL; const u32 b3_requ = 0x0F200000UL; const u32 b3_erro = 0x0D200000UL; const u32 b4_mask = 0xF8C0C0C0UL; const u32 b4_patt = 0xF0808080UL; const u32 b4_requ = 0x07300000UL; const u32 b4_err0 = 0x04000000UL; const u32 b4_err1 = 0x03300000UL; #elif YYJSON_ENDIAN == YYJSON_LITTLE_ENDIAN const u16 b2_mask = 0xC0E0UL; const u16 b2_patt = 0x80C0UL; const u16 b2_requ = 0x001EUL; const u32 b3_mask = 0x00C0C0F0UL; const u32 b3_patt = 0x008080E0UL; const u32 b3_requ = 0x0000200FUL; const u32 b3_erro = 0x0000200DUL; const u32 b4_mask = 0xC0C0C0F8UL; const u32 b4_patt = 0x808080F0UL; const u32 b4_requ = 0x00003007UL; const u32 b4_err0 = 0x00000004UL; const u32 b4_err1 = 0x00003003UL; #else /* this should be evaluated at compile-time */ v16_uni b2_mask_uni = {{ 0xE0, 0xC0 }}; v16_uni b2_patt_uni = {{ 0xC0, 0x80 }}; v16_uni b2_requ_uni = {{ 0x1E, 0x00 }}; v32_uni b3_mask_uni = {{ 0xF0, 0xC0, 0xC0, 0x00 }}; v32_uni b3_patt_uni = {{ 0xE0, 0x80, 0x80, 0x00 }}; v32_uni b3_requ_uni = {{ 0x0F, 0x20, 0x00, 0x00 }}; v32_uni b3_erro_uni = {{ 0x0D, 0x20, 0x00, 0x00 }}; v32_uni b4_mask_uni = {{ 0xF8, 0xC0, 0xC0, 0xC0 }}; v32_uni b4_patt_uni = {{ 0xF0, 0x80, 0x80, 0x80 }}; v32_uni b4_requ_uni = {{ 0x07, 0x30, 0x00, 0x00 }}; v32_uni b4_err0_uni = {{ 0x04, 0x00, 0x00, 0x00 }}; v32_uni b4_err1_uni = {{ 0x03, 0x30, 0x00, 0x00 }}; u16 b2_mask = b2_mask_uni.u; u16 b2_patt = b2_patt_uni.u; u16 b2_requ = b2_requ_uni.u; u32 b3_mask = b3_mask_uni.u; u32 b3_patt = b3_patt_uni.u; u32 b3_requ = b3_requ_uni.u; u32 b3_erro = b3_erro_uni.u; u32 b4_mask = b4_mask_uni.u; u32 b4_patt = b4_patt_uni.u; u32 b4_requ = b4_requ_uni.u; u32 b4_err0 = b4_err0_uni.u; u32 b4_err1 = b4_err1_uni.u; #endif #define is_valid_seq_2(uni) ( \ ((uni & b2_mask) == b2_patt) && \ ((uni & b2_requ)) \ ) #define is_valid_seq_3(uni) ( \ ((uni & b3_mask) == b3_patt) && \ ((tmp = (uni & b3_requ))) && \ ((tmp != b3_erro)) \ ) #define is_valid_seq_4(uni) ( \ ((uni & b4_mask) == b4_patt) && \ ((tmp = (uni & b4_requ))) && \ ((tmp & b4_err0) == 0 || (tmp & b4_err1) == 0) \ ) /* The replacement character U+FFFD, used to indicate invalid character. */ const v32 rep = {{ 'F', 'F', 'F', 'D' }}; const v32 pre = {{ '\\', 'u', '0', '0' }}; const u8 *src = str; const u8 *end = str + str_len; *cur++ = '"'; copy_ascii: /* Copy continuous ASCII, loop unrolling, same as the following code: while (end > src) ( if (unlikely(enc_table[*src])) break; *cur++ = *src++; ); */ #define expr_jump(i) \ if (unlikely(enc_table[src[i]])) goto stop_char_##i; #define expr_stop(i) \ stop_char_##i: \ memcpy(cur, src, i); \ cur += i; src += i; goto copy_utf8; while (end - src >= 16) { repeat16_incr(expr_jump) byte_copy_16(cur, src); cur += 16; src += 16; } while (end - src >= 4) { repeat4_incr(expr_jump) byte_copy_4(cur, src); cur += 4; src += 4; } while (end > src) { expr_jump(0) *cur++ = *src++; } *cur++ = '"'; return cur; repeat16_incr(expr_stop) #undef expr_jump #undef expr_stop copy_utf8: if (unlikely(src + 4 > end)) { if (end == src) goto copy_end; if (end - src < enc_table[*src] / 2) goto err_one; } switch (enc_table[*src]) { case CHAR_ENC_CPY_1: { *cur++ = *src++; goto copy_ascii; } case CHAR_ENC_CPY_2: { u16 v; #if YYJSON_DISABLE_UTF8_VALIDATION byte_copy_2(cur, src); #else v = byte_load_2(src); if (unlikely(!is_valid_seq_2(v))) goto err_cpy; byte_copy_2(cur, src); #endif cur += 2; src += 2; goto copy_utf8; } case CHAR_ENC_CPY_3: { u32 v, tmp; #if YYJSON_DISABLE_UTF8_VALIDATION if (likely(src + 4 <= end)) { byte_copy_4(cur, src); } else { byte_copy_2(cur, src); cur[2] = src[2]; } #else if (likely(src + 4 <= end)) { v = byte_load_4(src); if (unlikely(!is_valid_seq_3(v))) goto err_cpy; byte_copy_4(cur, src); } else { v = byte_load_3(src); if (unlikely(!is_valid_seq_3(v))) goto err_cpy; byte_copy_4(cur, &v); } #endif cur += 3; src += 3; goto copy_utf8; } case CHAR_ENC_CPY_4: { u32 v, tmp; #if YYJSON_DISABLE_UTF8_VALIDATION byte_copy_4(cur, src); #else v = byte_load_4(src); if (unlikely(!is_valid_seq_4(v))) goto err_cpy; byte_copy_4(cur, src); #endif cur += 4; src += 4; goto copy_utf8; } case CHAR_ENC_ESC_A: { byte_copy_2(cur, &esc_single_char_table[*src * 2]); cur += 2; src += 1; goto copy_utf8; } case CHAR_ENC_ESC_1: { byte_copy_4(cur + 0, &pre); byte_copy_2(cur + 4, &esc_hex_char_table[*src * 2]); cur += 6; src += 1; goto copy_utf8; } case CHAR_ENC_ESC_2: { u16 u, v; #if !YYJSON_DISABLE_UTF8_VALIDATION v = byte_load_2(src); if (unlikely(!is_valid_seq_2(v))) goto err_esc; #endif u = (u16)(((u16)(src[0] & 0x1F) << 6) | ((u16)(src[1] & 0x3F) << 0)); byte_copy_2(cur + 0, &pre); byte_copy_2(cur + 2, &esc_hex_char_table[(u >> 8) * 2]); byte_copy_2(cur + 4, &esc_hex_char_table[(u & 0xFF) * 2]); cur += 6; src += 2; goto copy_utf8; } case CHAR_ENC_ESC_3: { u16 u; u32 v, tmp; #if !YYJSON_DISABLE_UTF8_VALIDATION v = byte_load_3(src); if (unlikely(!is_valid_seq_3(v))) goto err_esc; #endif u = (u16)(((u16)(src[0] & 0x0F) << 12) | ((u16)(src[1] & 0x3F) << 6) | ((u16)(src[2] & 0x3F) << 0)); byte_copy_2(cur + 0, &pre); byte_copy_2(cur + 2, &esc_hex_char_table[(u >> 8) * 2]); byte_copy_2(cur + 4, &esc_hex_char_table[(u & 0xFF) * 2]); cur += 6; src += 3; goto copy_utf8; } case CHAR_ENC_ESC_4: { u32 hi, lo, u, v, tmp; #if !YYJSON_DISABLE_UTF8_VALIDATION v = byte_load_4(src); if (unlikely(!is_valid_seq_4(v))) goto err_esc; #endif u = ((u32)(src[0] & 0x07) << 18) | ((u32)(src[1] & 0x3F) << 12) | ((u32)(src[2] & 0x3F) << 6) | ((u32)(src[3] & 0x3F) << 0); u -= 0x10000; hi = (u >> 10) + 0xD800; lo = (u & 0x3FF) + 0xDC00; byte_copy_2(cur + 0, &pre); byte_copy_2(cur + 2, &esc_hex_char_table[(hi >> 8) * 2]); byte_copy_2(cur + 4, &esc_hex_char_table[(hi & 0xFF) * 2]); byte_copy_2(cur + 6, &pre); byte_copy_2(cur + 8, &esc_hex_char_table[(lo >> 8) * 2]); byte_copy_2(cur + 10, &esc_hex_char_table[(lo & 0xFF) * 2]); cur += 12; src += 4; goto copy_utf8; } case CHAR_ENC_ERR_1: { goto err_one; } default: break; } copy_end: *cur++ = '"'; return cur; err_one: if (esc) goto err_esc; else goto err_cpy; err_cpy: if (!inv) return NULL; *cur++ = *src++; goto copy_utf8; err_esc: if (!inv) return NULL; byte_copy_2(cur + 0, &pre); byte_copy_4(cur + 2, &rep); cur += 6; src += 1; goto copy_utf8; #undef is_valid_seq_2 #undef is_valid_seq_3 #undef is_valid_seq_4 } /*============================================================================== * Writer Utilities *============================================================================*/ /** Write null (requires 8 bytes buffer). */ static_inline u8 *write_null(u8 *cur) { v64 v = {{ 'n', 'u', 'l', 'l', ',', '\n', 0, 0 }}; byte_copy_8(cur, &v); return cur + 4; } /** Write bool (requires 8 bytes buffer). */ static_inline u8 *write_bool(u8 *cur, bool val) { v64 v0 = {{ 'f', 'a', 'l', 's', 'e', ',', '\n', 0 }}; v64 v1 = {{ 't', 'r', 'u', 'e', ',', '\n', 0, 0 }}; if (val) { byte_copy_8(cur, &v1); } else { byte_copy_8(cur, &v0); } return cur + 5 - val; } /** Write indent (requires level x 4 bytes buffer). Param spaces should not larger than 4. */ static_inline u8 *write_indent(u8 *cur, usize level, usize spaces) { while (level-- > 0) { byte_copy_4(cur, " "); cur += spaces; } return cur; } /** Write data to file pointer. */ static bool write_dat_to_fp(FILE *fp, u8 *dat, usize len, yyjson_write_err *err) { if (fwrite(dat, len, 1, fp) != 1) { err->msg = "file writing failed"; err->code = YYJSON_WRITE_ERROR_FILE_WRITE; return false; } return true; } /** Write data to file. */ static bool write_dat_to_file(const char *path, u8 *dat, usize len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ err->msg = _msg; \ err->code = YYJSON_WRITE_ERROR_##_code; \ if (file) fclose(file); \ return false; \ } while (false) FILE *file = fopen_writeonly(path); if (file == NULL) { return_err(FILE_OPEN, "file opening failed"); } if (fwrite(dat, len, 1, file) != 1) { return_err(FILE_WRITE, "file writing failed"); } if (fclose(file) != 0) { file = NULL; return_err(FILE_WRITE, "file closing failed"); } return true; #undef return_err } /*============================================================================== * JSON Writer Implementation *============================================================================*/ typedef struct yyjson_write_ctx { usize tag; } yyjson_write_ctx; static_inline void yyjson_write_ctx_set(yyjson_write_ctx *ctx, usize size, bool is_obj) { ctx->tag = (size << 1) | (usize)is_obj; } static_inline void yyjson_write_ctx_get(yyjson_write_ctx *ctx, usize *size, bool *is_obj) { usize tag = ctx->tag; *size = tag >> 1; *is_obj = (bool)(tag & 1); } /** Write single JSON value. */ static_inline u8 *yyjson_write_single(yyjson_val *val, yyjson_write_flag flg, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ if (hdr) alc.free(alc.ctx, (void *)hdr); \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ err->msg = _msg; \ return NULL; \ } while (false) #define incr_len(_len) do { \ hdr = (u8 *)alc.malloc(alc.ctx, _len); \ if (!hdr) goto fail_alloc; \ cur = hdr; \ } while (false) #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) u8 *hdr = NULL, *cur; usize str_len; const u8 *str_ptr; const char_enc_type *enc_table = get_enc_table_with_flag(flg); bool cpy = (enc_table == enc_table_cpy); bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; const usize end_len = 2; /* '\n' and '\0' */ switch (unsafe_yyjson_get_type(val)) { case YYJSON_TYPE_RAW: str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len + end_len); cur = write_raw(cur, str_ptr, str_len); break; case YYJSON_TYPE_STR: str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 2 + end_len); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { cur = write_string_noesc(cur, str_ptr, str_len); } else { cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } break; case YYJSON_TYPE_NUM: incr_len(32 + end_len); cur = write_number(cur, val, flg); if (unlikely(!cur)) goto fail_num; break; case YYJSON_TYPE_BOOL: incr_len(8); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); break; case YYJSON_TYPE_NULL: incr_len(8); cur = write_null(cur); break; case YYJSON_TYPE_ARR: incr_len(2 + end_len); byte_copy_2(cur, "[]"); cur += 2; break; case YYJSON_TYPE_OBJ: incr_len(2 + end_len); byte_copy_2(cur, "{}"); cur += 2; break; default: goto fail_type; } if (newline) *cur++ = '\n'; *cur = '\0'; *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; fail_alloc: return_err(MEMORY_ALLOCATION, "memory allocation failed"); fail_type: return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); fail_num: return_err(NAN_OR_INF, "nan or inf number is not allowed"); fail_str: return_err(INVALID_STRING, "invalid utf-8 encoding in string"); #undef return_err #undef check_str_len #undef incr_len } /** Write JSON document minify. The root of this document should be a non-empty container. */ static_inline u8 *yyjson_write_minify(const yyjson_val *root, const yyjson_write_flag flg, const yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ err->msg = _msg; \ if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ goto fail_alloc; \ alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ ctx = ctx_tmp; \ cur = tmp + (cur - hdr); \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) yyjson_val *val; yyjson_type val_type; usize ctn_len, ctn_len_tmp; bool ctn_obj, ctn_obj_tmp, is_key; u8 *hdr, *cur, *end, *tmp; yyjson_write_ctx *ctx, *ctx_tmp; usize alc_len, alc_inc, ctx_len, ext_len, str_len; const u8 *str_ptr; const char_enc_type *enc_table = get_enc_table_with_flag(flg); bool cpy = (enc_table == enc_table_cpy); bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; alc_len = root->uni.ofs / sizeof(yyjson_val); alc_len = alc_len * YYJSON_WRITER_ESTIMATED_MINIFY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); if (!hdr) goto fail_alloc; cur = hdr; end = hdr + alc_len; ctx = (yyjson_write_ctx *)(void *)end; doc_begin: val = constcast(yyjson_val *)root; val_type = unsafe_yyjson_get_type(val); ctn_obj = (val_type == YYJSON_TYPE_OBJ); ctn_len = unsafe_yyjson_get_len(val) << (u8)ctn_obj; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); val++; val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { is_key = ((u8)ctn_obj & (u8)~ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 16); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { cur = write_string_noesc(cur, str_ptr, str_len); } else { cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { incr_len(32); cur = write_number(cur, val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; goto val_end; } if ((val_type & (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) == (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) { ctn_len_tmp = unsafe_yyjson_get_len(val); ctn_obj_tmp = (val_type == YYJSON_TYPE_OBJ); incr_len(16); if (unlikely(ctn_len_tmp == 0)) { /* write empty container */ *cur++ = (u8)('[' | ((u8)ctn_obj_tmp << 5)); *cur++ = (u8)(']' | ((u8)ctn_obj_tmp << 5)); *cur++ = ','; goto val_end; } else { /* push context, setup new container */ yyjson_write_ctx_set(--ctx, ctn_len, ctn_obj); ctn_len = ctn_len_tmp << (u8)ctn_obj_tmp; ctn_obj = ctn_obj_tmp; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); val++; goto val_begin; } } if (val_type == YYJSON_TYPE_BOOL) { incr_len(16); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); cur++; goto val_end; } if (val_type == YYJSON_TYPE_NULL) { incr_len(16); cur = write_null(cur); cur++; goto val_end; } if (val_type == YYJSON_TYPE_RAW) { str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len + 2); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; goto val_end; } goto fail_type; val_end: val++; ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; goto val_begin; ctn_end: cur--; *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); *cur++ = ','; if (unlikely((u8 *)ctx >= end)) goto doc_end; yyjson_write_ctx_get(ctx++, &ctn_len, &ctn_obj); ctn_len--; if (likely(ctn_len > 0)) { goto val_begin; } else { goto ctn_end; } doc_end: if (newline) { incr_len(2); *(cur - 1) = '\n'; cur++; } *--cur = '\0'; *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; fail_alloc: return_err(MEMORY_ALLOCATION, "memory allocation failed"); fail_type: return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); fail_num: return_err(NAN_OR_INF, "nan or inf number is not allowed"); fail_str: return_err(INVALID_STRING, "invalid utf-8 encoding in string"); #undef return_err #undef incr_len #undef check_str_len } /** Write JSON document pretty. The root of this document should be a non-empty container. */ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, const yyjson_write_flag flg, const yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ err->msg = _msg; \ if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ goto fail_alloc; \ alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ ctx = ctx_tmp; \ cur = tmp + (cur - hdr); \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) yyjson_val *val; yyjson_type val_type; usize ctn_len, ctn_len_tmp; bool ctn_obj, ctn_obj_tmp, is_key, no_indent; u8 *hdr, *cur, *end, *tmp; yyjson_write_ctx *ctx, *ctx_tmp; usize alc_len, alc_inc, ctx_len, ext_len, str_len, level; const u8 *str_ptr; const char_enc_type *enc_table = get_enc_table_with_flag(flg); bool cpy = (enc_table == enc_table_cpy); bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; usize spaces = has_write_flag(PRETTY_TWO_SPACES) ? 2 : 4; bool newline = has_write_flag(NEWLINE_AT_END) != 0; alc_len = root->uni.ofs / sizeof(yyjson_val); alc_len = alc_len * YYJSON_WRITER_ESTIMATED_PRETTY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); if (!hdr) goto fail_alloc; cur = hdr; end = hdr + alc_len; ctx = (yyjson_write_ctx *)(void *)end; doc_begin: val = constcast(yyjson_val *)root; val_type = unsafe_yyjson_get_type(val); ctn_obj = (val_type == YYJSON_TYPE_OBJ); ctn_len = unsafe_yyjson_get_len(val) << (u8)ctn_obj; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); *cur++ = '\n'; val++; level = 1; val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { is_key = (bool)((u8)ctn_obj & (u8)~ctn_len); no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { cur = write_string_noesc(cur, str_ptr, str_len); } else { cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; *cur++ = is_key ? ' ' : '\n'; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(32 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_number(cur, val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; *cur++ = '\n'; goto val_end; } if ((val_type & (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) == (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); ctn_len_tmp = unsafe_yyjson_get_len(val); ctn_obj_tmp = (val_type == YYJSON_TYPE_OBJ); if (unlikely(ctn_len_tmp == 0)) { /* write empty container */ incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); *cur++ = (u8)('[' | ((u8)ctn_obj_tmp << 5)); *cur++ = (u8)(']' | ((u8)ctn_obj_tmp << 5)); *cur++ = ','; *cur++ = '\n'; goto val_end; } else { /* push context, setup new container */ incr_len(32 + (no_indent ? 0 : level * 4)); yyjson_write_ctx_set(--ctx, ctn_len, ctn_obj); ctn_len = ctn_len_tmp << (u8)ctn_obj_tmp; ctn_obj = ctn_obj_tmp; cur = write_indent(cur, no_indent ? 0 : level, spaces); level++; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); *cur++ = '\n'; val++; goto val_begin; } } if (val_type == YYJSON_TYPE_BOOL) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); cur += 2; goto val_end; } if (val_type == YYJSON_TYPE_NULL) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_null(cur); cur += 2; goto val_end; } if (val_type == YYJSON_TYPE_RAW) { str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len + 3); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; *cur++ = '\n'; goto val_end; } goto fail_type; val_end: val++; ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; goto val_begin; ctn_end: cur -= 2; *cur++ = '\n'; incr_len(level * 4); cur = write_indent(cur, --level, spaces); *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); if (unlikely((u8 *)ctx >= end)) goto doc_end; yyjson_write_ctx_get(ctx++, &ctn_len, &ctn_obj); ctn_len--; *cur++ = ','; *cur++ = '\n'; if (likely(ctn_len > 0)) { goto val_begin; } else { goto ctn_end; } doc_end: if (newline) { incr_len(2); *cur++ = '\n'; } *cur = '\0'; *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; fail_alloc: return_err(MEMORY_ALLOCATION, "memory allocation failed"); fail_type: return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); fail_num: return_err(NAN_OR_INF, "nan or inf number is not allowed"); fail_str: return_err(INVALID_STRING, "invalid utf-8 encoding in string"); #undef return_err #undef incr_len #undef check_str_len } char *yyjson_val_write_opts(const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err) { yyjson_write_err dummy_err; usize dummy_dat_len; yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_val *root = constcast(yyjson_val *)val; err = err ? err : &dummy_err; dat_len = dat_len ? dat_len : &dummy_dat_len; if (unlikely(!root)) { *dat_len = 0; err->msg = "input JSON is NULL"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return NULL; } if (!unsafe_yyjson_is_ctn(root) || unsafe_yyjson_get_len(root) == 0) { return (char *)yyjson_write_single(root, flg, alc, dat_len, err); } else if (flg & (YYJSON_WRITE_PRETTY | YYJSON_WRITE_PRETTY_TWO_SPACES)) { return (char *)yyjson_write_pretty(root, flg, alc, dat_len, err); } else { return (char *)yyjson_write_minify(root, flg, alc, dat_len, err); } } char *yyjson_write_opts(const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err) { yyjson_val *root = doc ? doc->root : NULL; return yyjson_val_write_opts(root, flg, alc_ptr, dat_len, err); } bool yyjson_val_write_file(const char *path, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; u8 *dat; usize dat_len = 0; yyjson_val *root = constcast(yyjson_val *)val; bool suc; alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; err = err ? err : &dummy_err; if (unlikely(!path || !*path)) { err->msg = "input path is invalid"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return false; } dat = (u8 *)yyjson_val_write_opts(root, flg, alc_ptr, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_file(path, dat, dat_len, err); alc_ptr->free(alc_ptr->ctx, dat); return suc; } bool yyjson_val_write_fp(FILE *fp, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; u8 *dat; usize dat_len = 0; yyjson_val *root = constcast(yyjson_val *)val; bool suc; alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; err = err ? err : &dummy_err; if (unlikely(!fp)) { err->msg = "input fp is invalid"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return false; } dat = (u8 *)yyjson_val_write_opts(root, flg, alc_ptr, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_fp(fp, dat, dat_len, err); alc_ptr->free(alc_ptr->ctx, dat); return suc; } bool yyjson_write_file(const char *path, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_val *root = doc ? doc->root : NULL; return yyjson_val_write_file(path, root, flg, alc_ptr, err); } bool yyjson_write_fp(FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_val *root = doc ? doc->root : NULL; return yyjson_val_write_fp(fp, root, flg, alc_ptr, err); } /*============================================================================== * Mutable JSON Writer Implementation *============================================================================*/ typedef struct yyjson_mut_write_ctx { usize tag; yyjson_mut_val *ctn; } yyjson_mut_write_ctx; static_inline void yyjson_mut_write_ctx_set(yyjson_mut_write_ctx *ctx, yyjson_mut_val *ctn, usize size, bool is_obj) { ctx->tag = (size << 1) | (usize)is_obj; ctx->ctn = ctn; } static_inline void yyjson_mut_write_ctx_get(yyjson_mut_write_ctx *ctx, yyjson_mut_val **ctn, usize *size, bool *is_obj) { usize tag = ctx->tag; *size = tag >> 1; *is_obj = (bool)(tag & 1); *ctn = ctx->ctn; } /** Get the estimated number of values for the mutable JSON document. */ static_inline usize yyjson_mut_doc_estimated_val_num( const yyjson_mut_doc *doc) { usize sum = 0; yyjson_val_chunk *chunk = doc->val_pool.chunks; while (chunk) { sum += chunk->chunk_size / sizeof(yyjson_mut_val) - 1; if (chunk == doc->val_pool.chunks) { sum -= (usize)(doc->val_pool.end - doc->val_pool.cur); } chunk = chunk->next; } return sum; } /** Write single JSON value. */ static_inline u8 *yyjson_mut_write_single(yyjson_mut_val *val, yyjson_write_flag flg, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { return yyjson_write_single((yyjson_val *)val, flg, alc, dat_len, err); } /** Write JSON document minify. The root of this document should be a non-empty container. */ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, usize estimated_val_num, yyjson_write_flag flg, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ err->msg = _msg; \ if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ goto fail_alloc; \ alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ ctx = ctx_tmp; \ cur = tmp + (cur - hdr); \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) yyjson_mut_val *val, *ctn; yyjson_type val_type; usize ctn_len, ctn_len_tmp; bool ctn_obj, ctn_obj_tmp, is_key; u8 *hdr, *cur, *end, *tmp; yyjson_mut_write_ctx *ctx, *ctx_tmp; usize alc_len, alc_inc, ctx_len, ext_len, str_len; const u8 *str_ptr; const char_enc_type *enc_table = get_enc_table_with_flag(flg); bool cpy = (enc_table == enc_table_cpy); bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; alc_len = estimated_val_num * YYJSON_WRITER_ESTIMATED_MINIFY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_mut_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); if (!hdr) goto fail_alloc; cur = hdr; end = hdr + alc_len; ctx = (yyjson_mut_write_ctx *)(void *)end; doc_begin: val = constcast(yyjson_mut_val *)root; val_type = unsafe_yyjson_get_type(val); ctn_obj = (val_type == YYJSON_TYPE_OBJ); ctn_len = unsafe_yyjson_get_len(val) << (u8)ctn_obj; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); ctn = val; val = (yyjson_mut_val *)val->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { is_key = ((u8)ctn_obj & (u8)~ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 16); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { cur = write_string_noesc(cur, str_ptr, str_len); } else { cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { incr_len(32); cur = write_number(cur, (yyjson_val *)val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; goto val_end; } if ((val_type & (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) == (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) { ctn_len_tmp = unsafe_yyjson_get_len(val); ctn_obj_tmp = (val_type == YYJSON_TYPE_OBJ); incr_len(16); if (unlikely(ctn_len_tmp == 0)) { /* write empty container */ *cur++ = (u8)('[' | ((u8)ctn_obj_tmp << 5)); *cur++ = (u8)(']' | ((u8)ctn_obj_tmp << 5)); *cur++ = ','; goto val_end; } else { /* push context, setup new container */ yyjson_mut_write_ctx_set(--ctx, ctn, ctn_len, ctn_obj); ctn_len = ctn_len_tmp << (u8)ctn_obj_tmp; ctn_obj = ctn_obj_tmp; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); ctn = val; val = (yyjson_mut_val *)ctn->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; goto val_begin; } } if (val_type == YYJSON_TYPE_BOOL) { incr_len(16); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); cur++; goto val_end; } if (val_type == YYJSON_TYPE_NULL) { incr_len(16); cur = write_null(cur); cur++; goto val_end; } if (val_type == YYJSON_TYPE_RAW) { str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len + 2); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; goto val_end; } goto fail_type; val_end: ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; val = val->next; goto val_begin; ctn_end: cur--; *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); *cur++ = ','; if (unlikely((u8 *)ctx >= end)) goto doc_end; val = ctn->next; yyjson_mut_write_ctx_get(ctx++, &ctn, &ctn_len, &ctn_obj); ctn_len--; if (likely(ctn_len > 0)) { goto val_begin; } else { goto ctn_end; } doc_end: if (newline) { incr_len(2); *(cur - 1) = '\n'; cur++; } *--cur = '\0'; *dat_len = (usize)(cur - hdr); err->code = YYJSON_WRITE_SUCCESS; err->msg = "success"; return hdr; fail_alloc: return_err(MEMORY_ALLOCATION, "memory allocation failed"); fail_type: return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); fail_num: return_err(NAN_OR_INF, "nan or inf number is not allowed"); fail_str: return_err(INVALID_STRING, "invalid utf-8 encoding in string"); #undef return_err #undef incr_len #undef check_str_len } /** Write JSON document pretty. The root of this document should be a non-empty container. */ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, usize estimated_val_num, yyjson_write_flag flg, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ err->msg = _msg; \ if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ goto fail_alloc; \ alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ ctx = ctx_tmp; \ cur = tmp + (cur - hdr); \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) yyjson_mut_val *val, *ctn; yyjson_type val_type; usize ctn_len, ctn_len_tmp; bool ctn_obj, ctn_obj_tmp, is_key, no_indent; u8 *hdr, *cur, *end, *tmp; yyjson_mut_write_ctx *ctx, *ctx_tmp; usize alc_len, alc_inc, ctx_len, ext_len, str_len, level; const u8 *str_ptr; const char_enc_type *enc_table = get_enc_table_with_flag(flg); bool cpy = (enc_table == enc_table_cpy); bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; usize spaces = has_write_flag(PRETTY_TWO_SPACES) ? 2 : 4; bool newline = has_write_flag(NEWLINE_AT_END) != 0; alc_len = estimated_val_num * YYJSON_WRITER_ESTIMATED_PRETTY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_mut_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); if (!hdr) goto fail_alloc; cur = hdr; end = hdr + alc_len; ctx = (yyjson_mut_write_ctx *)(void *)end; doc_begin: val = constcast(yyjson_mut_val *)root; val_type = unsafe_yyjson_get_type(val); ctn_obj = (val_type == YYJSON_TYPE_OBJ); ctn_len = unsafe_yyjson_get_len(val) << (u8)ctn_obj; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); *cur++ = '\n'; ctn = val; val = (yyjson_mut_val *)val->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; level = 1; val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { is_key = (bool)((u8)ctn_obj & (u8)~ctn_len); no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { cur = write_string_noesc(cur, str_ptr, str_len); } else { cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; *cur++ = is_key ? ' ' : '\n'; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(32 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_number(cur, (yyjson_val *)val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; *cur++ = '\n'; goto val_end; } if ((val_type & (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) == (YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ)) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); ctn_len_tmp = unsafe_yyjson_get_len(val); ctn_obj_tmp = (val_type == YYJSON_TYPE_OBJ); if (unlikely(ctn_len_tmp == 0)) { /* write empty container */ incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); *cur++ = (u8)('[' | ((u8)ctn_obj_tmp << 5)); *cur++ = (u8)(']' | ((u8)ctn_obj_tmp << 5)); *cur++ = ','; *cur++ = '\n'; goto val_end; } else { /* push context, setup new container */ incr_len(32 + (no_indent ? 0 : level * 4)); yyjson_mut_write_ctx_set(--ctx, ctn, ctn_len, ctn_obj); ctn_len = ctn_len_tmp << (u8)ctn_obj_tmp; ctn_obj = ctn_obj_tmp; cur = write_indent(cur, no_indent ? 0 : level, spaces); level++; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); *cur++ = '\n'; ctn = val; val = (yyjson_mut_val *)ctn->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; goto val_begin; } } if (val_type == YYJSON_TYPE_BOOL) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); cur += 2; goto val_end; } if (val_type == YYJSON_TYPE_NULL) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); incr_len(16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_null(cur); cur += 2; goto val_end; } if (val_type == YYJSON_TYPE_RAW) { str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len + 3); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; *cur++ = '\n'; goto val_end; } goto fail_type; val_end: ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; val = val->next; goto val_begin; ctn_end: cur -= 2; *cur++ = '\n'; incr_len(level * 4); cur = write_indent(cur, --level, spaces); *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); if (unlikely((u8 *)ctx >= end)) goto doc_end; val = ctn->next; yyjson_mut_write_ctx_get(ctx++, &ctn, &ctn_len, &ctn_obj); ctn_len--; *cur++ = ','; *cur++ = '\n'; if (likely(ctn_len > 0)) { goto val_begin; } else { goto ctn_end; } doc_end: if (newline) { incr_len(2); *cur++ = '\n'; } *cur = '\0'; *dat_len = (usize)(cur - hdr); err->code = YYJSON_WRITE_SUCCESS; err->msg = "success"; return hdr; fail_alloc: return_err(MEMORY_ALLOCATION, "memory allocation failed"); fail_type: return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); fail_num: return_err(NAN_OR_INF, "nan or inf number is not allowed"); fail_str: return_err(INVALID_STRING, "invalid utf-8 encoding in string"); #undef return_err #undef incr_len #undef check_str_len } static char *yyjson_mut_write_opts_impl(const yyjson_mut_val *val, usize estimated_val_num, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err) { yyjson_write_err dummy_err; usize dummy_dat_len; yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; err = err ? err : &dummy_err; dat_len = dat_len ? dat_len : &dummy_dat_len; if (unlikely(!root)) { *dat_len = 0; err->msg = "input JSON is NULL"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return NULL; } if (!unsafe_yyjson_is_ctn(root) || unsafe_yyjson_get_len(root) == 0) { return (char *)yyjson_mut_write_single(root, flg, alc, dat_len, err); } else if (flg & (YYJSON_WRITE_PRETTY | YYJSON_WRITE_PRETTY_TWO_SPACES)) { return (char *)yyjson_mut_write_pretty(root, estimated_val_num, flg, alc, dat_len, err); } else { return (char *)yyjson_mut_write_minify(root, estimated_val_num, flg, alc, dat_len, err); } } char *yyjson_mut_val_write_opts(const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err) { return yyjson_mut_write_opts_impl(val, 0, flg, alc_ptr, dat_len, err); } char *yyjson_mut_write_opts(const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err) { yyjson_mut_val *root; usize estimated_val_num; if (likely(doc)) { root = doc->root; estimated_val_num = yyjson_mut_doc_estimated_val_num(doc); } else { root = NULL; estimated_val_num = 0; } return yyjson_mut_write_opts_impl(root, estimated_val_num, flg, alc_ptr, dat_len, err); } bool yyjson_mut_val_write_file(const char *path, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; u8 *dat; usize dat_len = 0; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; bool suc; alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; err = err ? err : &dummy_err; if (unlikely(!path || !*path)) { err->msg = "input path is invalid"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return false; } dat = (u8 *)yyjson_mut_val_write_opts(root, flg, alc_ptr, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_file(path, dat, dat_len, err); alc_ptr->free(alc_ptr->ctx, dat); return suc; } bool yyjson_mut_val_write_fp(FILE *fp, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; u8 *dat; usize dat_len = 0; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; bool suc; alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; err = err ? err : &dummy_err; if (unlikely(!fp)) { err->msg = "input fp is invalid"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return false; } dat = (u8 *)yyjson_mut_val_write_opts(root, flg, alc_ptr, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_fp(fp, dat, dat_len, err); alc_ptr->free(alc_ptr->ctx, dat); return suc; } bool yyjson_mut_write_file(const char *path, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_mut_val *root = doc ? doc->root : NULL; return yyjson_mut_val_write_file(path, root, flg, alc_ptr, err); } bool yyjson_mut_write_fp(FILE *fp, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_mut_val *root = doc ? doc->root : NULL; return yyjson_mut_val_write_fp(fp, root, flg, alc_ptr, err); } #endif /* YYJSON_DISABLE_WRITER */ orjson-3.9.15/include/yyjson/yyjson.h000066400000000000000000011272111456615046100176220ustar00rootroot00000000000000/*============================================================================== Copyright (c) 2020 YaoYuan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *============================================================================*/ /** @file yyjson.h @date 2019-03-09 @author YaoYuan */ #ifndef YYJSON_H #define YYJSON_H /*============================================================================== * Header Files *============================================================================*/ #include #include #include #include #include #include /*============================================================================== * Compile-time Options *============================================================================*/ /* Define as 1 to disable JSON reader if JSON parsing is not required. This will disable these functions at compile-time: - yyjson_read() - yyjson_read_opts() - yyjson_read_file() - yyjson_read_number() - yyjson_mut_read_number() This will reduce the binary size by about 60%. */ #ifndef YYJSON_DISABLE_READER #endif /* Define as 1 to disable JSON writer if JSON serialization is not required. This will disable these functions at compile-time: - yyjson_write() - yyjson_write_file() - yyjson_write_opts() - yyjson_val_write() - yyjson_val_write_file() - yyjson_val_write_opts() - yyjson_mut_write() - yyjson_mut_write_file() - yyjson_mut_write_opts() - yyjson_mut_val_write() - yyjson_mut_val_write_file() - yyjson_mut_val_write_opts() This will reduce the binary size by about 30%. */ #ifndef YYJSON_DISABLE_WRITER #endif /* Define as 1 to disable JSON Pointer, JSON Patch and JSON Merge Patch supports. This will disable these functions at compile-time: - yyjson_ptr_xxx() - yyjson_mut_ptr_xxx() - yyjson_doc_ptr_xxx() - yyjson_mut_doc_ptr_xxx() - yyjson_patch() - yyjson_mut_patch() - yyjson_merge_patch() - yyjson_mut_merge_patch() */ #ifndef YYJSON_DISABLE_UTILS #endif /* Define as 1 to disable the fast floating-point number conversion in yyjson, and use libc's `strtod/snprintf` instead. This will reduce the binary size by about 30%, but significantly slow down the floating-point read/write speed. */ #ifndef YYJSON_DISABLE_FAST_FP_CONV #endif /* Define as 1 to disable non-standard JSON support at compile-time: - Reading and writing inf/nan literal, such as `NaN`, `-Infinity`. - Single line and multiple line comments. - Single trailing comma at the end of an object or array. - Invalid unicode in string value. This will also invalidate these run-time options: - YYJSON_READ_ALLOW_INF_AND_NAN - YYJSON_READ_ALLOW_COMMENTS - YYJSON_READ_ALLOW_TRAILING_COMMAS - YYJSON_READ_ALLOW_INVALID_UNICODE - YYJSON_WRITE_ALLOW_INF_AND_NAN - YYJSON_WRITE_ALLOW_INVALID_UNICODE This will reduce the binary size by about 10%, and speed up the reading and writing speed by about 2% to 6%. */ #ifndef YYJSON_DISABLE_NON_STANDARD #endif /* Define as 1 to disable UTF-8 validation at compile time. If all input strings are guaranteed to be valid UTF-8 encoding (for example, some language's String object has already validated the encoding), using this flag can avoid redundant UTF-8 validation in yyjson. This flag can speed up the reading and writing speed of non-ASCII encoded strings by about 3% to 7%. Note: If this flag is used while passing in illegal UTF-8 strings, the following errors may occur: - Escaped characters may be ignored when parsing JSON strings. - Ending quotes may be ignored when parsing JSON strings, causing the string to be concatenated to the next value. - When accessing `yyjson_mut_val` for serialization, the string ending may be accessed out of bounds, causing a segmentation fault. */ #ifndef YYJSON_DISABLE_UTF8_VALIDATION #endif /* Define as 1 to indicate that the target architecture does not support unaligned memory access. Please refer to the comments in the C file for details. */ #ifndef YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS #endif /* Define as 1 to export symbols when building this library as Windows DLL. */ #ifndef YYJSON_EXPORTS #endif /* Define as 1 to import symbols when using this library as Windows DLL. */ #ifndef YYJSON_IMPORTS #endif /* Define as 1 to include for compiler which doesn't support C99. */ #ifndef YYJSON_HAS_STDINT_H #endif /* Define as 1 to include for compiler which doesn't support C99. */ #ifndef YYJSON_HAS_STDBOOL_H #endif /*============================================================================== * Compiler Macros *============================================================================*/ /** compiler version (MSVC) */ #ifdef _MSC_VER # define YYJSON_MSC_VER _MSC_VER #else # define YYJSON_MSC_VER 0 #endif /** compiler version (GCC) */ #ifdef __GNUC__ # define YYJSON_GCC_VER __GNUC__ # if defined(__GNUC_PATCHLEVEL__) # define yyjson_gcc_available(major, minor, patch) \ ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ >= (major * 10000 + minor * 100 + patch)) # else # define yyjson_gcc_available(major, minor, patch) \ ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) \ >= (major * 10000 + minor * 100 + patch)) # endif #else # define YYJSON_GCC_VER 0 # define yyjson_gcc_available(major, minor, patch) 0 #endif /** real gcc check */ #if !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__ICC) && \ defined(__GNUC__) # define YYJSON_IS_REAL_GCC 1 #else # define YYJSON_IS_REAL_GCC 0 #endif /** C version (STDC) */ #if defined(__STDC__) && (__STDC__ >= 1) && defined(__STDC_VERSION__) # define YYJSON_STDC_VER __STDC_VERSION__ #else # define YYJSON_STDC_VER 0 #endif /** C++ version */ #if defined(__cplusplus) # define YYJSON_CPP_VER __cplusplus #else # define YYJSON_CPP_VER 0 #endif /** compiler builtin check (since gcc 10.0, clang 2.6, icc 2021) */ #ifndef yyjson_has_builtin # ifdef __has_builtin # define yyjson_has_builtin(x) __has_builtin(x) # else # define yyjson_has_builtin(x) 0 # endif #endif /** compiler attribute check (since gcc 5.0, clang 2.9, icc 17) */ #ifndef yyjson_has_attribute # ifdef __has_attribute # define yyjson_has_attribute(x) __has_attribute(x) # else # define yyjson_has_attribute(x) 0 # endif #endif /** compiler feature check (since clang 2.6, icc 17) */ #ifndef yyjson_has_feature # ifdef __has_feature # define yyjson_has_feature(x) __has_feature(x) # else # define yyjson_has_feature(x) 0 # endif #endif /** include check (since gcc 5.0, clang 2.7, icc 16, msvc 2017 15.3) */ #ifndef yyjson_has_include # ifdef __has_include # define yyjson_has_include(x) __has_include(x) # else # define yyjson_has_include(x) 0 # endif #endif /** inline for compiler */ #ifndef yyjson_inline # if YYJSON_MSC_VER >= 1200 # define yyjson_inline __forceinline # elif defined(_MSC_VER) # define yyjson_inline __inline # elif yyjson_has_attribute(always_inline) || YYJSON_GCC_VER >= 4 # define yyjson_inline __inline__ __attribute__((always_inline)) # elif defined(__clang__) || defined(__GNUC__) # define yyjson_inline __inline__ # elif defined(__cplusplus) || YYJSON_STDC_VER >= 199901L # define yyjson_inline inline # else # define yyjson_inline # endif #endif /** noinline for compiler */ #ifndef yyjson_noinline # if YYJSON_MSC_VER >= 1400 # define yyjson_noinline __declspec(noinline) # elif yyjson_has_attribute(noinline) || YYJSON_GCC_VER >= 4 # define yyjson_noinline __attribute__((noinline)) # else # define yyjson_noinline # endif #endif /** align for compiler */ #ifndef yyjson_align # if YYJSON_MSC_VER >= 1300 # define yyjson_align(x) __declspec(align(x)) # elif yyjson_has_attribute(aligned) || defined(__GNUC__) # define yyjson_align(x) __attribute__((aligned(x))) # elif YYJSON_CPP_VER >= 201103L # define yyjson_align(x) alignas(x) # else # define yyjson_align(x) # endif #endif /** likely for compiler */ #ifndef yyjson_likely # if yyjson_has_builtin(__builtin_expect) || \ (YYJSON_GCC_VER >= 4 && YYJSON_GCC_VER != 5) # define yyjson_likely(expr) __builtin_expect(!!(expr), 1) # else # define yyjson_likely(expr) (expr) # endif #endif /** unlikely for compiler */ #ifndef yyjson_unlikely # if yyjson_has_builtin(__builtin_expect) || \ (YYJSON_GCC_VER >= 4 && YYJSON_GCC_VER != 5) # define yyjson_unlikely(expr) __builtin_expect(!!(expr), 0) # else # define yyjson_unlikely(expr) (expr) # endif #endif /** compile-time constant check for compiler */ #ifndef yyjson_constant_p # if yyjson_has_builtin(__builtin_constant_p) || (YYJSON_GCC_VER >= 3) # define YYJSON_HAS_CONSTANT_P 1 # define yyjson_constant_p(value) __builtin_constant_p(value) # else # define YYJSON_HAS_CONSTANT_P 0 # define yyjson_constant_p(value) 0 # endif #endif /** deprecate warning */ #ifndef yyjson_deprecated # if YYJSON_MSC_VER >= 1400 # define yyjson_deprecated(msg) __declspec(deprecated(msg)) # elif yyjson_has_feature(attribute_deprecated_with_message) || \ (YYJSON_GCC_VER > 4 || (YYJSON_GCC_VER == 4 && __GNUC_MINOR__ >= 5)) # define yyjson_deprecated(msg) __attribute__((deprecated(msg))) # elif YYJSON_GCC_VER >= 3 # define yyjson_deprecated(msg) __attribute__((deprecated)) # else # define yyjson_deprecated(msg) # endif #endif /** function export */ #ifndef yyjson_api # if defined(_WIN32) # if defined(YYJSON_EXPORTS) && YYJSON_EXPORTS # define yyjson_api __declspec(dllexport) # elif defined(YYJSON_IMPORTS) && YYJSON_IMPORTS # define yyjson_api __declspec(dllimport) # else # define yyjson_api # endif # elif yyjson_has_attribute(visibility) || YYJSON_GCC_VER >= 4 # define yyjson_api __attribute__((visibility("default"))) # else # define yyjson_api # endif #endif /** inline function export */ #ifndef yyjson_api_inline # define yyjson_api_inline static yyjson_inline #endif /** stdint (C89 compatible) */ #if (defined(YYJSON_HAS_STDINT_H) && YYJSON_HAS_STDINT_H) || \ YYJSON_MSC_VER >= 1600 || YYJSON_STDC_VER >= 199901L || \ defined(_STDINT_H) || defined(_STDINT_H_) || \ defined(__CLANG_STDINT_H) || defined(_STDINT_H_INCLUDED) || \ yyjson_has_include() # include #elif defined(_MSC_VER) # if _MSC_VER < 1300 typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; # else typedef signed __int8 int8_t; typedef signed __int16 int16_t; typedef signed __int32 int32_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; # endif #else # if UCHAR_MAX == 0xFFU typedef signed char int8_t; typedef unsigned char uint8_t; # else # error cannot find 8-bit integer type # endif # if USHRT_MAX == 0xFFFFU typedef unsigned short uint16_t; typedef signed short int16_t; # elif UINT_MAX == 0xFFFFU typedef unsigned int uint16_t; typedef signed int int16_t; # else # error cannot find 16-bit integer type # endif # if UINT_MAX == 0xFFFFFFFFUL typedef unsigned int uint32_t; typedef signed int int32_t; # elif ULONG_MAX == 0xFFFFFFFFUL typedef unsigned long uint32_t; typedef signed long int32_t; # elif USHRT_MAX == 0xFFFFFFFFUL typedef unsigned short uint32_t; typedef signed short int32_t; # else # error cannot find 32-bit integer type # endif # if defined(__INT64_TYPE__) && defined(__UINT64_TYPE__) typedef __INT64_TYPE__ int64_t; typedef __UINT64_TYPE__ uint64_t; # elif defined(__GNUC__) || defined(__clang__) # if !defined(_SYS_TYPES_H) && !defined(__int8_t_defined) __extension__ typedef long long int64_t; # endif __extension__ typedef unsigned long long uint64_t; # elif defined(_LONG_LONG) || defined(__MWERKS__) || defined(_CRAYC) || \ defined(__SUNPRO_C) || defined(__SUNPRO_CC) typedef long long int64_t; typedef unsigned long long uint64_t; # elif (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || \ defined(__WATCOM_INT64__) || defined (__alpha) || defined (__DECC) typedef __int64 int64_t; typedef unsigned __int64 uint64_t; # else # error cannot find 64-bit integer type # endif #endif /** stdbool (C89 compatible) */ #if (defined(YYJSON_HAS_STDBOOL_H) && YYJSON_HAS_STDBOOL_H) || \ (yyjson_has_include() && !defined(__STRICT_ANSI__)) || \ YYJSON_MSC_VER >= 1800 || YYJSON_STDC_VER >= 199901L # include #elif !defined(__bool_true_false_are_defined) # define __bool_true_false_are_defined 1 # if defined(__cplusplus) # if defined(__GNUC__) && !defined(__STRICT_ANSI__) # define _Bool bool # if __cplusplus < 201103L # define bool bool # define false false # define true true # endif # endif # else # define bool unsigned char # define true 1 # define false 0 # endif #endif /** char bit check */ #if defined(CHAR_BIT) # if CHAR_BIT != 8 # error non 8-bit char is not supported # endif #endif /** Microsoft Visual C++ 6.0 doesn't support converting number from u64 to f64: error C2520: conversion from unsigned __int64 to double not implemented. */ #ifndef YYJSON_U64_TO_F64_NO_IMPL # if (0 < YYJSON_MSC_VER) && (YYJSON_MSC_VER <= 1200) # define YYJSON_U64_TO_F64_NO_IMPL 1 # else # define YYJSON_U64_TO_F64_NO_IMPL 0 # endif #endif /*============================================================================== * Compile Hint Begin *============================================================================*/ /* extern "C" begin */ #ifdef __cplusplus extern "C" { #endif /* warning suppress begin */ #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunused-function" # pragma clang diagnostic ignored "-Wunused-parameter" #elif defined(__GNUC__) # if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic push # endif # pragma GCC diagnostic ignored "-Wunused-function" # pragma GCC diagnostic ignored "-Wunused-parameter" #elif defined(_MSC_VER) # pragma warning(push) # pragma warning(disable:4800) /* 'int': forcing value to 'true' or 'false' */ #endif /*============================================================================== * Version *============================================================================*/ /** The major version of yyjson. */ #define YYJSON_VERSION_MAJOR 0 /** The minor version of yyjson. */ #define YYJSON_VERSION_MINOR 8 /** The patch version of yyjson. */ #define YYJSON_VERSION_PATCH 0 /** The version of yyjson in hex: `(major << 16) | (minor << 8) | (patch)`. */ #define YYJSON_VERSION_HEX 0x000800 /** The version string of yyjson. */ #define YYJSON_VERSION_STRING "0.8.0" /** The version of yyjson in hex, same as `YYJSON_VERSION_HEX`. */ yyjson_api uint32_t yyjson_version(void); /*============================================================================== * JSON Types *============================================================================*/ /** Type of a JSON value (3 bit). */ typedef uint8_t yyjson_type; /** No type, invalid. */ #define YYJSON_TYPE_NONE ((uint8_t)0) /* _____000 */ /** Raw string type, no subtype. */ #define YYJSON_TYPE_RAW ((uint8_t)1) /* _____001 */ /** Null type: `null` literal, no subtype. */ #define YYJSON_TYPE_NULL ((uint8_t)2) /* _____010 */ /** Boolean type, subtype: TRUE, FALSE. */ #define YYJSON_TYPE_BOOL ((uint8_t)3) /* _____011 */ /** Number type, subtype: UINT, SINT, REAL. */ #define YYJSON_TYPE_NUM ((uint8_t)4) /* _____100 */ /** String type, subtype: NONE, NOESC. */ #define YYJSON_TYPE_STR ((uint8_t)5) /* _____101 */ /** Array type, no subtype. */ #define YYJSON_TYPE_ARR ((uint8_t)6) /* _____110 */ /** Object type, no subtype. */ #define YYJSON_TYPE_OBJ ((uint8_t)7) /* _____111 */ /** Subtype of a JSON value (2 bit). */ typedef uint8_t yyjson_subtype; /** No subtype. */ #define YYJSON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */ /** False subtype: `false` literal. */ #define YYJSON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */ /** True subtype: `true` literal. */ #define YYJSON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */ /** Unsigned integer subtype: `uint64_t`. */ #define YYJSON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */ /** Signed integer subtype: `int64_t`. */ #define YYJSON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */ /** Real number subtype: `double`. */ #define YYJSON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */ /** String that do not need to be escaped for writing (internal use). */ #define YYJSON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */ /** The mask used to extract the type of a JSON value. */ #define YYJSON_TYPE_MASK ((uint8_t)0x07) /* _____111 */ /** The number of bits used by the type. */ #define YYJSON_TYPE_BIT ((uint8_t)3) /** The mask used to extract the subtype of a JSON value. */ #define YYJSON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */ /** The number of bits used by the subtype. */ #define YYJSON_SUBTYPE_BIT ((uint8_t)2) /** The mask used to extract the reserved bits of a JSON value. */ #define YYJSON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */ /** The number of reserved bits. */ #define YYJSON_RESERVED_BIT ((uint8_t)3) /** The mask used to extract the tag of a JSON value. */ #define YYJSON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */ /** The number of bits used by the tag. */ #define YYJSON_TAG_BIT ((uint8_t)8) /** Padding size for JSON reader. */ #define YYJSON_PADDING_SIZE 4 /*============================================================================== * Allocator *============================================================================*/ /** A memory allocator. Typically you don't need to use it, unless you want to customize your own memory allocator. */ typedef struct yyjson_alc { /** Same as libc's malloc(size), should not be NULL. */ void *(*malloc)(void *ctx, size_t size); /** Same as libc's realloc(ptr, size), should not be NULL. */ void *(*realloc)(void *ctx, void *ptr, size_t old_size, size_t size); /** Same as libc's free(ptr), should not be NULL. */ void (*free)(void *ctx, void *ptr); /** A context for malloc/realloc/free, can be NULL. */ void *ctx; } yyjson_alc; /** A pool allocator uses fixed length pre-allocated memory. This allocator may be used to avoid malloc/realloc calls. The pre-allocated memory should be held by the caller. The maximum amount of memory required to read a JSON can be calculated using the `yyjson_read_max_memory_usage()` function, but the amount of memory required to write a JSON cannot be directly calculated. This is not a general-purpose allocator. It is designed to handle a single JSON data at a time. If it is used for overly complex memory tasks, such as parsing multiple JSON documents using the same allocator but releasing only a few of them, it may cause memory fragmentation, resulting in performance degradation and memory waste. @param alc The allocator to be initialized. If this parameter is NULL, the function will fail and return false. If `buf` or `size` is invalid, this will be set to an empty allocator. @param buf The buffer memory for this allocator. If this parameter is NULL, the function will fail and return false. @param size The size of `buf`, in bytes. If this parameter is less than 8 words (32/64 bytes on 32/64-bit OS), the function will fail and return false. @return true if the `alc` has been successfully initialized. @par Example @code // parse JSON with stack memory char buf[1024]; yyjson_alc alc; yyjson_alc_pool_init(&alc, buf, 1024); const char *json = "{\"name\":\"Helvetica\",\"size\":16}" yyjson_doc *doc = yyjson_read_opts(json, strlen(json), 0, &alc, NULL); // the memory of `doc` is on the stack @endcode @warning This Allocator is not thread-safe. */ yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size); /** A dynamic allocator. This allocator has a similar usage to the pool allocator above. However, when there is not enough memory, this allocator will dynamically request more memory using libc's `malloc` function, and frees it all at once when it is destroyed. @return A new dynamic allocator, or NULL if memory allocation failed. @note The returned value should be freed with `yyjson_alc_dyn_free()`. @warning This Allocator is not thread-safe. */ yyjson_api yyjson_alc *yyjson_alc_dyn_new(void); /** Free a dynamic allocator which is created by `yyjson_alc_dyn_new()`. @param alc The dynamic allocator to be destroyed. */ yyjson_api void yyjson_alc_dyn_free(yyjson_alc *alc); /*============================================================================== * JSON Structure *============================================================================*/ /** An immutable document for reading JSON. This document holds memory for all its JSON values and strings. When it is no longer used, the user should call `yyjson_doc_free()` to free its memory. */ typedef struct yyjson_doc yyjson_doc; /** An immutable value for reading JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and and cannot be freed alone. */ typedef struct yyjson_val yyjson_val; /** A mutable document for building JSON. This document holds memory for all its JSON values and strings. When it is no longer used, the user should call `yyjson_mut_doc_free()` to free its memory. */ typedef struct yyjson_mut_doc yyjson_mut_doc; /** A mutable value for building JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and and cannot be freed alone. */ typedef struct yyjson_mut_val yyjson_mut_val; /*============================================================================== * JSON Reader API *============================================================================*/ /** Run-time options for JSON reader. */ typedef uint32_t yyjson_read_flag; /** Default option (RFC 8259 compliant): - Read positive integer as uint64_t. - Read negative integer as int64_t. - Read floating-point number as double with round-to-nearest mode. - Read integer which cannot fit in uint64_t or int64_t as double. - Report error if double number is infinity. - Report error if string contains invalid UTF-8 character or BOM. - Report error on trailing commas, comments, inf and nan literals. */ static const yyjson_read_flag YYJSON_READ_NOFLAG = 0; /** Read the input data in-situ. This option allows the reader to modify and use input data to store string values, which can increase reading speed slightly. The caller should hold the input data before free the document. The input data must be padded by at least `YYJSON_PADDING_SIZE` bytes. For example: `[1,2]` should be `[1,2]\0\0\0\0`, input length should be 5. */ static const yyjson_read_flag YYJSON_READ_INSITU = 1 << 0; /** Stop when done instead of issuing an error if there's additional content after a JSON document. This option may be used to parse small pieces of JSON in larger data, such as `NDJSON`. */ static const yyjson_read_flag YYJSON_READ_STOP_WHEN_DONE = 1 << 1; /** Allow single trailing comma at the end of an object or array, such as `[1,2,3,]`, `{"a":1,"b":2,}` (non-standard). */ static const yyjson_read_flag YYJSON_READ_ALLOW_TRAILING_COMMAS = 1 << 2; /** Allow C-style single line and multiple line comments (non-standard). */ static const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS = 1 << 3; /** Allow inf/nan number and literal, case-insensitive, such as 1e999, NaN, inf, -Infinity (non-standard). */ static const yyjson_read_flag YYJSON_READ_ALLOW_INF_AND_NAN = 1 << 4; /** Read all numbers as raw strings (value with `YYJSON_TYPE_RAW` type), inf/nan literal is also read as raw with `ALLOW_INF_AND_NAN` flag. */ static const yyjson_read_flag YYJSON_READ_NUMBER_AS_RAW = 1 << 5; /** Allow reading invalid unicode when parsing string values (non-standard). Invalid characters will be allowed to appear in the string values, but invalid escape sequences will still be reported as errors. This flag does not affect the performance of correctly encoded strings. @warning Strings in JSON values may contain incorrect encoding when this option is used, you need to handle these strings carefully to avoid security risks. */ static const yyjson_read_flag YYJSON_READ_ALLOW_INVALID_UNICODE = 1 << 6; /** Read big numbers as raw strings. These big numbers include integers that cannot be represented by `int64_t` and `uint64_t`, and floating-point numbers that cannot be represented by finite `double`. The flag will be overridden by `YYJSON_READ_NUMBER_AS_RAW` flag. */ static const yyjson_read_flag YYJSON_READ_BIGNUM_AS_RAW = 1 << 7; /** Result code for JSON reader. */ typedef uint32_t yyjson_read_code; /** Success, no error. */ static const yyjson_read_code YYJSON_READ_SUCCESS = 0; /** Invalid parameter, such as NULL input string or 0 input length. */ static const yyjson_read_code YYJSON_READ_ERROR_INVALID_PARAMETER = 1; /** Memory allocation failure occurs. */ static const yyjson_read_code YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2; /** Input JSON string is empty. */ static const yyjson_read_code YYJSON_READ_ERROR_EMPTY_CONTENT = 3; /** Unexpected content after document, such as `[123]abc`. */ static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4; /** Unexpected ending, such as `[123`. */ static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END = 5; /** Unexpected character inside the document, such as `[abc]`. */ static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6; /** Invalid JSON structure, such as `[1,]`. */ static const yyjson_read_code YYJSON_READ_ERROR_JSON_STRUCTURE = 7; /** Invalid comment, such as unclosed multi-line comment. */ static const yyjson_read_code YYJSON_READ_ERROR_INVALID_COMMENT = 8; /** Invalid number, such as `123.e12`, `000`. */ static const yyjson_read_code YYJSON_READ_ERROR_INVALID_NUMBER = 9; /** Invalid string, such as invalid escaped character inside a string. */ static const yyjson_read_code YYJSON_READ_ERROR_INVALID_STRING = 10; /** Invalid JSON literal, such as `truu`. */ static const yyjson_read_code YYJSON_READ_ERROR_LITERAL = 11; /** Failed to open a file. */ static const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12; /** Failed to read a file. */ static const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13; /** Document exceeded YYJSON_READER_CONTAINER_RECURSION_LIMIT. */ static const yyjson_read_code YYJSON_READ_ERROR_RECURSION_DEPTH = 14; /** Error information for JSON reader. */ typedef struct yyjson_read_err { /** Error code, see `yyjson_read_code` for all possible values. */ yyjson_read_code code; /** Error message, constant, no need to free (NULL if success). */ const char *msg; /** Error byte position for input data (0 if success). */ size_t pos; } yyjson_read_err; /** Read JSON with options. This function is thread-safe when: 1. The `dat` is not modified by other threads. 2. The `alc` is thread-safe or NULL. @param dat The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. The `dat` will not be modified without the flag `YYJSON_READ_INSITU`, so you can pass a `const char *` string and case it to `char *` if you don't use the `YYJSON_READ_INSITU` flag. @param len The length of JSON data in bytes. If this parameter is 0, the function will fail and return NULL. @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. */ yyjson_api yyjson_doc *yyjson_read_opts(char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err); /** Read a JSON file. This function is thread-safe when: 1. The file is not modified by other threads. 2. The `alc` is thread-safe or NULL. @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return NULL. @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. @warning On 32-bit operating system, files larger than 2GB may fail to read. */ yyjson_api yyjson_doc *yyjson_read_file(const char *path, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err); /** Read JSON from a file pointer. @param fp The file pointer. The data will be read from the current position of the FILE to the end. If this fp is NULL or invalid, the function will fail and return NULL. @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. @warning On 32-bit operating system, files larger than 2GB may fail to read. */ yyjson_api yyjson_doc *yyjson_read_fp(FILE *fp, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err); /** Read a JSON string. This function is thread-safe. @param dat The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. @param len The length of JSON data in bytes. If this parameter is 0, the function will fail and return NULL. @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. */ yyjson_api_inline yyjson_doc *yyjson_read(const char *dat, size_t len, yyjson_read_flag flg) { flg &= ~YYJSON_READ_INSITU; /* const string cannot be modified */ return yyjson_read_opts((char *)(void *)(size_t)(const void *)dat, len, flg, NULL, NULL); } /** Returns the size of maximum memory usage to read a JSON data. You may use this value to avoid malloc() or calloc() call inside the reader to get better performance, or read multiple JSON with one piece of memory. @param len The length of JSON data in bytes. @param flg The JSON read options. @return The maximum memory size to read this JSON, or 0 if overflow. @par Example @code // read multiple JSON with same pre-allocated memory char *dat1, *dat2, *dat3; // JSON data size_t len1, len2, len3; // JSON length size_t max_len = MAX(len1, MAX(len2, len3)); yyjson_doc *doc; // use one allocator for multiple JSON size_t size = yyjson_read_max_memory_usage(max_len, 0); void *buf = malloc(size); yyjson_alc alc; yyjson_alc_pool_init(&alc, buf, size); // no more alloc() or realloc() call during reading doc = yyjson_read_opts(dat1, len1, 0, &alc, NULL); yyjson_doc_free(doc); doc = yyjson_read_opts(dat2, len2, 0, &alc, NULL); yyjson_doc_free(doc); doc = yyjson_read_opts(dat3, len3, 0, &alc, NULL); yyjson_doc_free(doc); free(buf); @endcode @see yyjson_alc_pool_init() */ yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, yyjson_read_flag flg) { /* 1. The max value count is (json_size / 2 + 1), for example: "[1,2,3,4]" size is 9, value count is 5. 2. Some broken JSON may cost more memory during reading, but fail at end, for example: "[[[[[[[[". 3. yyjson use 16 bytes per value, see struct yyjson_val. 4. yyjson use dynamic memory with a growth factor of 1.5. The max memory size is (json_size / 2 * 16 * 1.5 + padding). */ size_t mul = (size_t)12 + !(flg & YYJSON_READ_INSITU); size_t pad = 256; size_t max = (size_t)(~(size_t)0); if (flg & YYJSON_READ_STOP_WHEN_DONE) len = len < 256 ? 256 : len; if (len >= (max - pad - mul) / mul) return 0; return len * mul + pad; } /** Read a JSON number. This function is thread-safe when data is not modified by other threads. @param dat The JSON data (UTF-8 without BOM), null-terminator is required. If this parameter is NULL, the function will fail and return NULL. @param val The output value where result is stored. If this parameter is NULL, the function will fail and return NULL. The value will hold either UINT or SINT or REAL number; @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. Supports `YYJSON_READ_NUMBER_AS_RAW` and `YYJSON_READ_ALLOW_INF_AND_NAN`. @param alc The memory allocator used for long number. It is only used when the built-in floating point reader is disabled. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return If successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs. */ yyjson_api const char *yyjson_read_number(const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err); /** Read a JSON number. This function is thread-safe when data is not modified by other threads. @param dat The JSON data (UTF-8 without BOM), null-terminator is required. If this parameter is NULL, the function will fail and return NULL. @param val The output value where result is stored. If this parameter is NULL, the function will fail and return NULL. The value will hold either UINT or SINT or REAL number; @param flg The JSON read options. Multiple options can be combined with `|` operator. 0 means no options. Supports `YYJSON_READ_NUMBER_AS_RAW` and `YYJSON_READ_ALLOW_INF_AND_NAN`. @param alc The memory allocator used for long number. It is only used when the built-in floating point reader is disabled. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return If successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs. */ yyjson_api_inline const char *yyjson_mut_read_number(const char *dat, yyjson_mut_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err) { return yyjson_read_number(dat, (yyjson_val *)val, flg, alc, err); } /*============================================================================== * JSON Writer API *============================================================================*/ /** Run-time options for JSON writer. */ typedef uint32_t yyjson_write_flag; /** Default option: - Write JSON minify. - Report error on inf or nan number. - Report error on invalid UTF-8 string. - Do not escape unicode or slash. */ static const yyjson_write_flag YYJSON_WRITE_NOFLAG = 0; /** Write JSON pretty with 4 space indent. */ static const yyjson_write_flag YYJSON_WRITE_PRETTY = 1 << 0; /** Escape unicode as `uXXXX`, make the output ASCII only. */ static const yyjson_write_flag YYJSON_WRITE_ESCAPE_UNICODE = 1 << 1; /** Escape '/' as '\/'. */ static const yyjson_write_flag YYJSON_WRITE_ESCAPE_SLASHES = 1 << 2; /** Write inf and nan number as 'Infinity' and 'NaN' literal (non-standard). */ static const yyjson_write_flag YYJSON_WRITE_ALLOW_INF_AND_NAN = 1 << 3; /** Write inf and nan number as null literal. This flag will override `YYJSON_WRITE_ALLOW_INF_AND_NAN` flag. */ static const yyjson_write_flag YYJSON_WRITE_INF_AND_NAN_AS_NULL = 1 << 4; /** Allow invalid unicode when encoding string values (non-standard). Invalid characters in string value will be copied byte by byte. If `YYJSON_WRITE_ESCAPE_UNICODE` flag is also set, invalid character will be escaped as `U+FFFD` (replacement character). This flag does not affect the performance of correctly encoded strings. */ static const yyjson_write_flag YYJSON_WRITE_ALLOW_INVALID_UNICODE = 1 << 5; /** Write JSON pretty with 2 space indent. This flag will override `YYJSON_WRITE_PRETTY` flag. */ static const yyjson_write_flag YYJSON_WRITE_PRETTY_TWO_SPACES = 1 << 6; /** Adds a newline character `\n` at the end of the JSON. This can be helpful for text editors or NDJSON. */ static const yyjson_write_flag YYJSON_WRITE_NEWLINE_AT_END = 1 << 7; /** Result code for JSON writer */ typedef uint32_t yyjson_write_code; /** Success, no error. */ static const yyjson_write_code YYJSON_WRITE_SUCCESS = 0; /** Invalid parameter, such as NULL document. */ static const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_PARAMETER = 1; /** Memory allocation failure occurs. */ static const yyjson_write_code YYJSON_WRITE_ERROR_MEMORY_ALLOCATION = 2; /** Invalid value type in JSON document. */ static const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE = 3; /** NaN or Infinity number occurs. */ static const yyjson_write_code YYJSON_WRITE_ERROR_NAN_OR_INF = 4; /** Failed to open a file. */ static const yyjson_write_code YYJSON_WRITE_ERROR_FILE_OPEN = 5; /** Failed to write a file. */ static const yyjson_write_code YYJSON_WRITE_ERROR_FILE_WRITE = 6; /** Invalid unicode in string. */ static const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_STRING = 7; /** Error information for JSON writer. */ typedef struct yyjson_write_err { /** Error code, see `yyjson_write_code` for all possible values. */ yyjson_write_code code; /** Error message, constant, no need to free (NULL if success). */ const char *msg; } yyjson_write_err; /*============================================================================== * JSON Document Writer API *============================================================================*/ /** Write a document to JSON string with options. This function is thread-safe when: The `alc` is thread-safe or NULL. @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free(). */ yyjson_api char *yyjson_write_opts(const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err); /** Write a document to JSON file with options. This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `alc` is thread-safe or NULL. @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_write_file(const char *path, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a document to file pointer with options. @param fp The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_write_fp(FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a document to JSON string. This function is thread-safe. @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free(). */ yyjson_api_inline char *yyjson_write(const yyjson_doc *doc, yyjson_write_flag flg, size_t *len) { return yyjson_write_opts(doc, flg, NULL, len, NULL); } /** Write a document to JSON string with options. This function is thread-safe when: 1. The `doc` is not modified by other threads. 2. The `alc` is thread-safe or NULL. @param doc The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free(). */ yyjson_api char *yyjson_mut_write_opts(const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err); /** Write a document to JSON file with options. This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `doc` is not modified by other threads. 3. The `alc` is thread-safe or NULL. @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @param doc The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_write_file(const char *path, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a document to file pointer with options. @param fp The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. @param doc The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_write_fp(FILE *fp, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a document to JSON string. This function is thread-safe when: The `doc` is not modified by other threads. @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free(). */ yyjson_api_inline char *yyjson_mut_write(const yyjson_mut_doc *doc, yyjson_write_flag flg, size_t *len) { return yyjson_mut_write_opts(doc, flg, NULL, len, NULL); } /*============================================================================== * JSON Value Writer API *============================================================================*/ /** Write a value to JSON string with options. This function is thread-safe when: The `alc` is thread-safe or NULL. @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free(). */ yyjson_api char *yyjson_val_write_opts(const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err); /** Write a value to JSON file with options. This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `alc` is thread-safe or NULL. @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_val_write_file(const char *path, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a value to file pointer with options. @param fp The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_val_write_fp(FILE *fp, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a value to JSON string. This function is thread-safe. @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free(). */ yyjson_api_inline char *yyjson_val_write(const yyjson_val *val, yyjson_write_flag flg, size_t *len) { return yyjson_val_write_opts(val, flg, NULL, len, NULL); } /** Write a value to JSON string with options. This function is thread-safe when: 1. The `val` is not modified by other threads. 2. The `alc` is thread-safe or NULL. @param val The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free(). */ yyjson_api char *yyjson_mut_val_write_opts(const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err); /** Write a value to JSON file with options. This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `val` is not modified by other threads. 3. The `alc` is thread-safe or NULL. @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @param val The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_val_write_file(const char *path, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a value to JSON file with options. @param fp The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. @param val The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param alc The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_val_write_fp(FILE *fp, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err); /** Write a value to JSON string. This function is thread-safe when: The `val` is not modified by other threads. @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. Multiple options can be combined with `|` operator. 0 means no options. @param len A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. @return A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free(). */ yyjson_api_inline char *yyjson_mut_val_write(const yyjson_mut_val *val, yyjson_write_flag flg, size_t *len) { return yyjson_mut_val_write_opts(val, flg, NULL, len, NULL); } /*============================================================================== * JSON Document API *============================================================================*/ /** Returns the root value of this JSON document. Returns NULL if `doc` is NULL. */ yyjson_api_inline yyjson_val *yyjson_doc_get_root(yyjson_doc *doc); /** Returns read size of input JSON data. Returns 0 if `doc` is NULL. For example: the read size of `[1,2,3]` is 7 bytes. */ yyjson_api_inline size_t yyjson_doc_get_read_size(yyjson_doc *doc); /** Returns total value count in this JSON document. Returns 0 if `doc` is NULL. For example: the value count of `[1,2,3]` is 4. */ yyjson_api_inline size_t yyjson_doc_get_val_count(yyjson_doc *doc); /** Release the JSON document and free the memory. After calling this function, the `doc` and all values from the `doc` are no longer available. This function will do nothing if the `doc` is NULL. */ yyjson_api void yyjson_doc_free(yyjson_doc *doc); /*============================================================================== * JSON Value Type API *============================================================================*/ /** Returns whether the JSON value is raw. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_raw(yyjson_val *val); /** Returns whether the JSON value is `null`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_null(yyjson_val *val); /** Returns whether the JSON value is `true`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_true(yyjson_val *val); /** Returns whether the JSON value is `false`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_false(yyjson_val *val); /** Returns whether the JSON value is bool (true/false). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_bool(yyjson_val *val); /** Returns whether the JSON value is unsigned integer (uint64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_uint(yyjson_val *val); /** Returns whether the JSON value is signed integer (int64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_sint(yyjson_val *val); /** Returns whether the JSON value is integer (uint64_t/int64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_int(yyjson_val *val); /** Returns whether the JSON value is real number (double). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_real(yyjson_val *val); /** Returns whether the JSON value is number (uint64_t/int64_t/double). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_num(yyjson_val *val); /** Returns whether the JSON value is string. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_str(yyjson_val *val); /** Returns whether the JSON value is array. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_arr(yyjson_val *val); /** Returns whether the JSON value is object. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_obj(yyjson_val *val); /** Returns whether the JSON value is container (array/object). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_is_ctn(yyjson_val *val); /*============================================================================== * JSON Value Content API *============================================================================*/ /** Returns the JSON value's type. Returns YYJSON_TYPE_NONE if `val` is NULL. */ yyjson_api_inline yyjson_type yyjson_get_type(yyjson_val *val); /** Returns the JSON value's subtype. Returns YYJSON_SUBTYPE_NONE if `val` is NULL. */ yyjson_api_inline yyjson_subtype yyjson_get_subtype(yyjson_val *val); /** Returns the JSON value's tag. Returns 0 if `val` is NULL. */ yyjson_api_inline uint8_t yyjson_get_tag(yyjson_val *val); /** Returns the JSON value's type description. The return value should be one of these strings: "raw", "null", "string", "array", "object", "true", "false", "uint", "sint", "real", "unknown". */ yyjson_api_inline const char *yyjson_get_type_desc(yyjson_val *val); /** Returns the content if the value is raw. Returns NULL if `val` is NULL or type is not raw. */ yyjson_api_inline const char *yyjson_get_raw(yyjson_val *val); /** Returns the content if the value is bool. Returns NULL if `val` is NULL or type is not bool. */ yyjson_api_inline bool yyjson_get_bool(yyjson_val *val); /** Returns the content and cast to uint64_t. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline uint64_t yyjson_get_uint(yyjson_val *val); /** Returns the content and cast to int64_t. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline int64_t yyjson_get_sint(yyjson_val *val); /** Returns the content and cast to int. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline int yyjson_get_int(yyjson_val *val); /** Returns the content if the value is real number, or 0.0 on error. Returns 0.0 if `val` is NULL or type is not real(double). */ yyjson_api_inline double yyjson_get_real(yyjson_val *val); /** Returns the content and typecast to `double` if the value is number. Returns 0.0 if `val` is NULL or type is not number(uint/sint/real). */ yyjson_api_inline double yyjson_get_num(yyjson_val *val); /** Returns the content if the value is string. Returns NULL if `val` is NULL or type is not string. */ yyjson_api_inline const char *yyjson_get_str(yyjson_val *val); /** Returns the content length (string length, array size, object size. Returns 0 if `val` is NULL or type is not string/array/object. */ yyjson_api_inline size_t yyjson_get_len(yyjson_val *val); /** Returns whether the JSON value is equals to a string. Returns false if input is NULL or type is not string. */ yyjson_api_inline bool yyjson_equals_str(yyjson_val *val, const char *str); /** Returns whether the JSON value is equals to a string. The `str` should be a UTF-8 string, null-terminator is not required. Returns false if input is NULL or type is not string. */ yyjson_api_inline bool yyjson_equals_strn(yyjson_val *val, const char *str, size_t len); /** Returns whether two JSON values are equal (deep compare). Returns false if input is NULL. @note the result may be inaccurate if object has duplicate keys. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api_inline bool yyjson_equals(yyjson_val *lhs, yyjson_val *rhs); /** Set the value to raw. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_raw(yyjson_val *val, const char *raw, size_t len); /** Set the value to null. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_null(yyjson_val *val); /** Set the value to bool. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_bool(yyjson_val *val, bool num); /** Set the value to uint. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_uint(yyjson_val *val, uint64_t num); /** Set the value to sint. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_sint(yyjson_val *val, int64_t num); /** Set the value to int. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_int(yyjson_val *val, int num); /** Set the value to real. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_real(yyjson_val *val, double num); /** Set the value to string (null-terminated). Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_str(yyjson_val *val, const char *str); /** Set the value to string (with length). Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_strn(yyjson_val *val, const char *str, size_t len); /*============================================================================== * JSON Array API *============================================================================*/ /** Returns the number of elements in this array. Returns 0 if `arr` is NULL or type is not array. */ yyjson_api_inline size_t yyjson_arr_size(yyjson_val *arr); /** Returns the element at the specified position in this array. Returns NULL if array is NULL/empty or the index is out of bounds. @warning This function takes a linear search time if array is not flat. For example: `[1,{},3]` is flat, `[1,[2],3]` is not flat. */ yyjson_api_inline yyjson_val *yyjson_arr_get(yyjson_val *arr, size_t idx); /** Returns the first element of this array. Returns NULL if `arr` is NULL/empty or type is not array. */ yyjson_api_inline yyjson_val *yyjson_arr_get_first(yyjson_val *arr); /** Returns the last element of this array. Returns NULL if `arr` is NULL/empty or type is not array. @warning This function takes a linear search time if array is not flat. For example: `[1,{},3]` is flat, `[1,[2],3]` is not flat.*/ yyjson_api_inline yyjson_val *yyjson_arr_get_last(yyjson_val *arr); /*============================================================================== * JSON Array Iterator API *============================================================================*/ /** A JSON array iterator. @par Example @code yyjson_val *val; yyjson_arr_iter iter = yyjson_arr_iter_with(arr); while ((val = yyjson_arr_iter_next(&iter))) { your_func(val); } @endcode */ typedef struct yyjson_arr_iter { size_t idx; /**< next value's index */ size_t max; /**< maximum index (arr.size) */ yyjson_val *cur; /**< next value */ } yyjson_arr_iter; /** Initialize an iterator for this array. @param arr The array to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_arr_iter_init(yyjson_val *arr, yyjson_arr_iter *iter); /** Create an iterator with an array , same as `yyjson_arr_iter_init()`. @param arr The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. @return A new iterator for the array. @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr); /** Returns whether the iteration has more elements. If `iter` is NULL, this function will return false. */ yyjson_api_inline bool yyjson_arr_iter_has_next(yyjson_arr_iter *iter); /** Returns the next element in the iteration, or NULL on end. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_val *yyjson_arr_iter_next(yyjson_arr_iter *iter); /** Macro for iterating over an array. It works like iterator, but with a more intuitive API. @par Example @code size_t idx, max; yyjson_val *val; yyjson_arr_foreach(arr, idx, max, val) { your_func(idx, val); } @endcode */ #define yyjson_arr_foreach(arr, idx, max, val) \ for ((idx) = 0, \ (max) = yyjson_arr_size(arr), \ (val) = yyjson_arr_get_first(arr); \ (idx) < (max); \ (idx)++, \ (val) = unsafe_yyjson_get_next(val)) /*============================================================================== * JSON Object API *============================================================================*/ /** Returns the number of key-value pairs in this object. Returns 0 if `obj` is NULL or type is not object. */ yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. The `key` should be a null-terminated UTF-8 string. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_val *yyjson_obj_get(yyjson_val *obj, const char *key); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. The `key` should be a UTF-8 string, null-terminator is not required. The `key_len` should be the length of the key, in bytes. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_val *yyjson_obj_getn(yyjson_val *obj, const char *key, size_t key_len); /*============================================================================== * JSON Object Iterator API *============================================================================*/ /** A JSON object iterator. @par Example @code yyjson_val *key, *val; yyjson_obj_iter iter = yyjson_obj_iter_with(obj); while ((key = yyjson_obj_iter_next(&iter))) { val = yyjson_obj_iter_get_val(key); your_func(key, val); } @endcode If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups: @code // {"k1":1, "k2": 3, "k3": 3} yyjson_val *key, *val; yyjson_obj_iter iter = yyjson_obj_iter_with(obj); yyjson_val *v1 = yyjson_obj_iter_get(&iter, "k1"); yyjson_val *v3 = yyjson_obj_iter_get(&iter, "k3"); @endcode @see yyjson_obj_iter_get() and yyjson_obj_iter_getn() */ typedef struct yyjson_obj_iter { size_t idx; /**< next key's index */ size_t max; /**< maximum key index (obj.size) */ yyjson_val *cur; /**< next key */ yyjson_val *obj; /**< the object being iterated */ } yyjson_obj_iter; /** Initialize an iterator for this object. @param obj The object to be iterated over. If this parameter is NULL or not an object, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_obj_iter_init(yyjson_val *obj, yyjson_obj_iter *iter); /** Create an iterator with an object, same as `yyjson_obj_iter_init()`. @param obj The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. @return A new iterator for the object. @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj); /** Returns whether the iteration has more elements. If `iter` is NULL, this function will return false. */ yyjson_api_inline bool yyjson_obj_iter_has_next(yyjson_obj_iter *iter); /** Returns the next key in the iteration, or NULL on end. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_next(yyjson_obj_iter *iter); /** Returns the value for key inside the iteration. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_get_val(yyjson_val *key); /** Iterates to a specified key and returns the value. This function does the same thing as `yyjson_obj_get()`, but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string with null-terminator. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key); /** Iterates to a specified key and returns the value. This function does the same thing as `yyjson_obj_getn()`, but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string, null-terminator is not required. @param key_len The the length of `key`, in bytes. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_getn(yyjson_obj_iter *iter, const char *key, size_t key_len); /** Macro for iterating over an object. It works like iterator, but with a more intuitive API. @par Example @code size_t idx, max; yyjson_val *key, *val; yyjson_obj_foreach(obj, idx, max, key, val) { your_func(key, val); } @endcode */ #define yyjson_obj_foreach(obj, idx, max, key, val) \ for ((idx) = 0, \ (max) = yyjson_obj_size(obj), \ (key) = (obj) ? unsafe_yyjson_get_first(obj) : NULL, \ (val) = (key) + 1; \ (idx) < (max); \ (idx)++, \ (key) = unsafe_yyjson_get_next(val), \ (val) = (key) + 1) /*============================================================================== * Mutable JSON Document API *============================================================================*/ /** Returns the root value of this JSON document. Returns NULL if `doc` is NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_get_root(yyjson_mut_doc *doc); /** Sets the root value of this JSON document. Pass NULL to clear root value of the document. */ yyjson_api_inline void yyjson_mut_doc_set_root(yyjson_mut_doc *doc, yyjson_mut_val *root); /** Set the string pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed. If the caller knows the approximate bytes of strings that the document needs to store (e.g. copy string with `yyjson_mut_strcpy` function), setting a larger size can avoid multiple memory allocations and improve performance. @param doc The mutable document. @param len The desired string pool size in bytes (total string length). @return true if successful, false if size is 0 or overflow. */ yyjson_api bool yyjson_mut_doc_set_str_pool_size(yyjson_mut_doc *doc, size_t len); /** Set the value pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed. If the caller knows the approximate number of values that the document needs to store (e.g. create new value with `yyjson_mut_xxx` functions), setting a larger size can avoid multiple memory allocations and improve performance. @param doc The mutable document. @param count The desired value pool size (number of `yyjson_mut_val`). @return true if successful, false if size is 0 or overflow. */ yyjson_api bool yyjson_mut_doc_set_val_pool_size(yyjson_mut_doc *doc, size_t count); /** Release the JSON document and free the memory. After calling this function, the `doc` and all values from the `doc` are no longer available. This function will do nothing if the `doc` is NULL. */ yyjson_api void yyjson_mut_doc_free(yyjson_mut_doc *doc); /** Creates and returns a new mutable JSON document, returns NULL on error. If allocator is NULL, the default allocator will be used. */ yyjson_api yyjson_mut_doc *yyjson_mut_doc_new(const yyjson_alc *alc); /** Copies and returns a new mutable document from input, returns NULL on error. This makes a `deep-copy` on the immutable document. If allocator is NULL, the default allocator will be used. @note `imut_doc` -> `mut_doc`. */ yyjson_api yyjson_mut_doc *yyjson_doc_mut_copy(yyjson_doc *doc, const yyjson_alc *alc); /** Copies and returns a new mutable document from input, returns NULL on error. This makes a `deep-copy` on the mutable document. If allocator is NULL, the default allocator will be used. @note `mut_doc` -> `mut_doc`. */ yyjson_api yyjson_mut_doc *yyjson_mut_doc_mut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc); /** Copies and returns a new mutable value from input, returns NULL on error. This makes a `deep-copy` on the immutable value. The memory was managed by mutable document. @note `imut_val` -> `mut_val`. */ yyjson_api yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *doc, yyjson_val *val); /** Copies and returns a new mutable value from input, returns NULL on error. This makes a `deep-copy` on the mutable value. The memory was managed by mutable document. @note `mut_val` -> `mut_val`. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api yyjson_mut_val *yyjson_mut_val_mut_copy(yyjson_mut_doc *doc, yyjson_mut_val *val); /** Copies and returns a new immutable document from input, returns NULL on error. This makes a `deep-copy` on the mutable document. The returned document should be freed with `yyjson_doc_free()`. @note `mut_doc` -> `imut_doc`. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api yyjson_doc *yyjson_mut_doc_imut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc); /** Copies and returns a new immutable document from input, returns NULL on error. This makes a `deep-copy` on the mutable value. The returned document should be freed with `yyjson_doc_free()`. @note `mut_val` -> `imut_doc`. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api yyjson_doc *yyjson_mut_val_imut_copy(yyjson_mut_val *val, const yyjson_alc *alc); /*============================================================================== * Mutable JSON Value Type API *============================================================================*/ /** Returns whether the JSON value is raw. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_raw(yyjson_mut_val *val); /** Returns whether the JSON value is `null`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_null(yyjson_mut_val *val); /** Returns whether the JSON value is `true`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_true(yyjson_mut_val *val); /** Returns whether the JSON value is `false`. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_false(yyjson_mut_val *val); /** Returns whether the JSON value is bool (true/false). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_bool(yyjson_mut_val *val); /** Returns whether the JSON value is unsigned integer (uint64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_uint(yyjson_mut_val *val); /** Returns whether the JSON value is signed integer (int64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_sint(yyjson_mut_val *val); /** Returns whether the JSON value is integer (uint64_t/int64_t). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_int(yyjson_mut_val *val); /** Returns whether the JSON value is real number (double). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_real(yyjson_mut_val *val); /** Returns whether the JSON value is number (uint/sint/real). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_num(yyjson_mut_val *val); /** Returns whether the JSON value is string. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_str(yyjson_mut_val *val); /** Returns whether the JSON value is array. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_arr(yyjson_mut_val *val); /** Returns whether the JSON value is object. Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_obj(yyjson_mut_val *val); /** Returns whether the JSON value is container (array/object). Returns false if `val` is NULL. */ yyjson_api_inline bool yyjson_mut_is_ctn(yyjson_mut_val *val); /*============================================================================== * Mutable JSON Value Content API *============================================================================*/ /** Returns the JSON value's type. Returns `YYJSON_TYPE_NONE` if `val` is NULL. */ yyjson_api_inline yyjson_type yyjson_mut_get_type(yyjson_mut_val *val); /** Returns the JSON value's subtype. Returns `YYJSON_SUBTYPE_NONE` if `val` is NULL. */ yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype(yyjson_mut_val *val); /** Returns the JSON value's tag. Returns 0 if `val` is NULL. */ yyjson_api_inline uint8_t yyjson_mut_get_tag(yyjson_mut_val *val); /** Returns the JSON value's type description. The return value should be one of these strings: "raw", "null", "string", "array", "object", "true", "false", "uint", "sint", "real", "unknown". */ yyjson_api_inline const char *yyjson_mut_get_type_desc(yyjson_mut_val *val); /** Returns the content if the value is raw. Returns NULL if `val` is NULL or type is not raw. */ yyjson_api_inline const char *yyjson_mut_get_raw(yyjson_mut_val *val); /** Returns the content if the value is bool. Returns NULL if `val` is NULL or type is not bool. */ yyjson_api_inline bool yyjson_mut_get_bool(yyjson_mut_val *val); /** Returns the content and cast to uint64_t. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline uint64_t yyjson_mut_get_uint(yyjson_mut_val *val); /** Returns the content and cast to int64_t. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline int64_t yyjson_mut_get_sint(yyjson_mut_val *val); /** Returns the content and cast to int. Returns 0 if `val` is NULL or type is not integer(sint/uint). */ yyjson_api_inline int yyjson_mut_get_int(yyjson_mut_val *val); /** Returns the content if the value is real number. Returns 0.0 if `val` is NULL or type is not real(double). */ yyjson_api_inline double yyjson_mut_get_real(yyjson_mut_val *val); /** Returns the content and typecast to `double` if the value is number. Returns 0.0 if `val` is NULL or type is not number(uint/sint/real). */ yyjson_api_inline double yyjson_mut_get_num(yyjson_mut_val *val); /** Returns the content if the value is string. Returns NULL if `val` is NULL or type is not string. */ yyjson_api_inline const char *yyjson_mut_get_str(yyjson_mut_val *val); /** Returns the content length (string length, array size, object size. Returns 0 if `val` is NULL or type is not string/array/object. */ yyjson_api_inline size_t yyjson_mut_get_len(yyjson_mut_val *val); /** Returns whether the JSON value is equals to a string. The `str` should be a null-terminated UTF-8 string. Returns false if input is NULL or type is not string. */ yyjson_api_inline bool yyjson_mut_equals_str(yyjson_mut_val *val, const char *str); /** Returns whether the JSON value is equals to a string. The `str` should be a UTF-8 string, null-terminator is not required. Returns false if input is NULL or type is not string. */ yyjson_api_inline bool yyjson_mut_equals_strn(yyjson_mut_val *val, const char *str, size_t len); /** Returns whether two JSON values are equal (deep compare). Returns false if input is NULL. @note the result may be inaccurate if object has duplicate keys. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api_inline bool yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs); /** Set the value to raw. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_raw(yyjson_mut_val *val, const char *raw, size_t len); /** Set the value to null. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_null(yyjson_mut_val *val); /** Set the value to bool. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_bool(yyjson_mut_val *val, bool num); /** Set the value to uint. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_uint(yyjson_mut_val *val, uint64_t num); /** Set the value to sint. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_sint(yyjson_mut_val *val, int64_t num); /** Set the value to int. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_int(yyjson_mut_val *val, int num); /** Set the value to real. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_real(yyjson_mut_val *val, double num); /** Set the value to string (null-terminated). Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_str(yyjson_mut_val *val, const char *str); /** Set the value to string (with length). Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_strn(yyjson_mut_val *val, const char *str, size_t len); /** Set the value to array. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_arr(yyjson_mut_val *val); /** Set the value to array. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_obj(yyjson_mut_val *val); /*============================================================================== * Mutable JSON Value Creation API *============================================================================*/ /** Creates and returns a raw value, returns NULL on error. The `str` should be a null-terminated UTF-8 string. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_raw(yyjson_mut_doc *doc, const char *str); /** Creates and returns a raw value, returns NULL on error. The `str` should be a UTF-8 string, null-terminator is not required. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_rawn(yyjson_mut_doc *doc, const char *str, size_t len); /** Creates and returns a raw value, returns NULL on error. The `str` should be a null-terminated UTF-8 string. The input string is copied and held by the document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_rawcpy(yyjson_mut_doc *doc, const char *str); /** Creates and returns a raw value, returns NULL on error. The `str` should be a UTF-8 string, null-terminator is not required. The input string is copied and held by the document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_rawncpy(yyjson_mut_doc *doc, const char *str, size_t len); /** Creates and returns a null value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_null(yyjson_mut_doc *doc); /** Creates and returns a true value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_true(yyjson_mut_doc *doc); /** Creates and returns a false value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_false(yyjson_mut_doc *doc); /** Creates and returns a bool value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_bool(yyjson_mut_doc *doc, bool val); /** Creates and returns an unsigned integer value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_uint(yyjson_mut_doc *doc, uint64_t num); /** Creates and returns a signed integer value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_sint(yyjson_mut_doc *doc, int64_t num); /** Creates and returns a signed integer value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_int(yyjson_mut_doc *doc, int64_t num); /** Creates and returns an real number value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_real(yyjson_mut_doc *doc, double num); /** Creates and returns a string value, returns NULL on error. The `str` should be a null-terminated UTF-8 string. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_str(yyjson_mut_doc *doc, const char *str); /** Creates and returns a string value, returns NULL on error. The `str` should be a UTF-8 string, null-terminator is not required. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_strn(yyjson_mut_doc *doc, const char *str, size_t len); /** Creates and returns a string value, returns NULL on error. The `str` should be a null-terminated UTF-8 string. The input string is copied and held by the document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_strcpy(yyjson_mut_doc *doc, const char *str); /** Creates and returns a string value, returns NULL on error. The `str` should be a UTF-8 string, null-terminator is not required. The input string is copied and held by the document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_strncpy(yyjson_mut_doc *doc, const char *str, size_t len); /*============================================================================== * Mutable JSON Array API *============================================================================*/ /** Returns the number of elements in this array. Returns 0 if `arr` is NULL or type is not array. */ yyjson_api_inline size_t yyjson_mut_arr_size(yyjson_mut_val *arr); /** Returns the element at the specified position in this array. Returns NULL if array is NULL/empty or the index is out of bounds. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get(yyjson_mut_val *arr, size_t idx); /** Returns the first element of this array. Returns NULL if `arr` is NULL/empty or type is not array. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get_first(yyjson_mut_val *arr); /** Returns the last element of this array. Returns NULL if `arr` is NULL/empty or type is not array. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get_last(yyjson_mut_val *arr); /*============================================================================== * Mutable JSON Array Iterator API *============================================================================*/ /** A mutable JSON array iterator. @warning You should not modify the array while iterating over it, but you can use `yyjson_mut_arr_iter_remove()` to remove current value. @par Example @code yyjson_mut_val *val; yyjson_mut_arr_iter iter = yyjson_mut_arr_iter_with(arr); while ((val = yyjson_mut_arr_iter_next(&iter))) { your_func(val); if (your_val_is_unused(val)) { yyjson_mut_arr_iter_remove(&iter); } } @endcode */ typedef struct yyjson_mut_arr_iter { size_t idx; /**< next value's index */ size_t max; /**< maximum index (arr.size) */ yyjson_mut_val *cur; /**< current value */ yyjson_mut_val *pre; /**< previous value */ yyjson_mut_val *arr; /**< the array being iterated */ } yyjson_mut_arr_iter; /** Initialize an iterator for this array. @param arr The array to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_mut_arr_iter_init(yyjson_mut_val *arr, yyjson_mut_arr_iter *iter); /** Create an iterator with an array , same as `yyjson_mut_arr_iter_init()`. @param arr The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. @return A new iterator for the array. @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with( yyjson_mut_val *arr); /** Returns whether the iteration has more elements. If `iter` is NULL, this function will return false. */ yyjson_api_inline bool yyjson_mut_arr_iter_has_next( yyjson_mut_arr_iter *iter); /** Returns the next element in the iteration, or NULL on end. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_next( yyjson_mut_arr_iter *iter); /** Removes and returns current element in the iteration. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_remove( yyjson_mut_arr_iter *iter); /** Macro for iterating over an array. It works like iterator, but with a more intuitive API. @warning You should not modify the array while iterating over it. @par Example @code size_t idx, max; yyjson_mut_val *val; yyjson_mut_arr_foreach(arr, idx, max, val) { your_func(idx, val); } @endcode */ #define yyjson_mut_arr_foreach(arr, idx, max, val) \ for ((idx) = 0, \ (max) = yyjson_mut_arr_size(arr), \ (val) = yyjson_mut_arr_get_first(arr); \ (idx) < (max); \ (idx)++, \ (val) = (val)->next) /*============================================================================== * Mutable JSON Array Creation API *============================================================================*/ /** Creates and returns an empty mutable array. @param doc A mutable document, used for memory allocation only. @return The new array. NULL if input is NULL or memory allocation failed. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr(yyjson_mut_doc *doc); /** Creates and returns a new mutable array with the given boolean values. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of boolean values. @param count The value count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const bool vals[3] = { true, false, true }; yyjson_mut_val *arr = yyjson_mut_arr_with_bool(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_bool( yyjson_mut_doc *doc, const bool *vals, size_t count); /** Creates and returns a new mutable array with the given sint numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of sint numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const int64_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint( yyjson_mut_doc *doc, const int64_t *vals, size_t count); /** Creates and returns a new mutable array with the given uint numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const uint64_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint( yyjson_mut_doc *doc, const uint64_t *vals, size_t count); /** Creates and returns a new mutable array with the given real numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of real numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const double vals[3] = { 0.1, 0.2, 0.3 }; yyjson_mut_val *arr = yyjson_mut_arr_with_real(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_real( yyjson_mut_doc *doc, const double *vals, size_t count); /** Creates and returns a new mutable array with the given int8 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int8 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const int8_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint8(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint8( yyjson_mut_doc *doc, const int8_t *vals, size_t count); /** Creates and returns a new mutable array with the given int16 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int16 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const int16_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint16(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint16( yyjson_mut_doc *doc, const int16_t *vals, size_t count); /** Creates and returns a new mutable array with the given int32 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int32 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const int32_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint32(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint32( yyjson_mut_doc *doc, const int32_t *vals, size_t count); /** Creates and returns a new mutable array with the given int64 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int64 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const int64_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint64( yyjson_mut_doc *doc, const int64_t *vals, size_t count); /** Creates and returns a new mutable array with the given uint8 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint8 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const uint8_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint8(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint8( yyjson_mut_doc *doc, const uint8_t *vals, size_t count); /** Creates and returns a new mutable array with the given uint16 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint16 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const uint16_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint16(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint16( yyjson_mut_doc *doc, const uint16_t *vals, size_t count); /** Creates and returns a new mutable array with the given uint32 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint32 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const uint32_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint32(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint32( yyjson_mut_doc *doc, const uint32_t *vals, size_t count); /** Creates and returns a new mutable array with the given uint64 numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint64 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const uint64_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint64(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint64( yyjson_mut_doc *doc, const uint64_t *vals, size_t count); /** Creates and returns a new mutable array with the given float numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of float numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const float vals[3] = { -1.0f, 0.0f, 1.0f }; yyjson_mut_val *arr = yyjson_mut_arr_with_float(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_float( yyjson_mut_doc *doc, const float *vals, size_t count); /** Creates and returns a new mutable array with the given double numbers. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of double numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const double vals[3] = { -1.0, 0.0, 1.0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_double(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_double( yyjson_mut_doc *doc, const double *vals, size_t count); /** Creates and returns a new mutable array with the given strings, these strings will not be copied. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. @param count The number of values in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @warning The input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use `yyjson_mut_arr_with_strcpy()` instead. @par Example @code const char *vals[3] = { "a", "b", "c" }; yyjson_mut_val *arr = yyjson_mut_arr_with_str(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_str( yyjson_mut_doc *doc, const char **vals, size_t count); /** Creates and returns a new mutable array with the given strings and string lengths, these strings will not be copied. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. @param lens A C array of string lengths, in bytes. @param count The number of strings in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @warning The input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use `yyjson_mut_arr_with_strncpy()` instead. @par Example @code const char *vals[3] = { "a", "bb", "c" }; const size_t lens[3] = { 1, 2, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strn( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count); /** Creates and returns a new mutable array with the given strings, these strings will be copied. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. @param count The number of values in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const char *vals[3] = { "a", "b", "c" }; yyjson_mut_val *arr = yyjson_mut_arr_with_strcpy(doc, vals, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strcpy( yyjson_mut_doc *doc, const char **vals, size_t count); /** Creates and returns a new mutable array with the given strings and string lengths, these strings will be copied. @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. @param lens A C array of string lengths, in bytes. @param count The number of strings in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. @par Example @code const char *vals[3] = { "a", "bb", "c" }; const size_t lens[3] = { 1, 2, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strncpy( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count); /*============================================================================== * Mutable JSON Array Modification API *============================================================================*/ /** Inserts a value into an array at a given index. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param val The value to be inserted. Returns false if it is NULL. @param idx The index to which to insert the new value. Returns false if the index is out of range. @return Whether successful. @warning This function takes a linear search time. */ yyjson_api_inline bool yyjson_mut_arr_insert(yyjson_mut_val *arr, yyjson_mut_val *val, size_t idx); /** Inserts a value at the end of the array. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param val The value to be inserted. Returns false if it is NULL. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_append(yyjson_mut_val *arr, yyjson_mut_val *val); /** Inserts a value at the head of the array. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param val The value to be inserted. Returns false if it is NULL. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_prepend(yyjson_mut_val *arr, yyjson_mut_val *val); /** Replaces a value at index and returns old value. @param arr The array to which the value is to be replaced. Returns false if it is NULL or not an array. @param idx The index to which to replace the value. Returns false if the index is out of range. @param val The new value to replace. Returns false if it is NULL. @return Old value, or NULL on error. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_replace(yyjson_mut_val *arr, size_t idx, yyjson_mut_val *val); /** Removes and returns a value at index. @param arr The array from which the value is to be removed. Returns false if it is NULL or not an array. @param idx The index from which to remove the value. Returns false if the index is out of range. @return Old value, or NULL on error. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove(yyjson_mut_val *arr, size_t idx); /** Removes and returns the first value in this array. @param arr The array from which the value is to be removed. Returns false if it is NULL or not an array. @return The first value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove_first( yyjson_mut_val *arr); /** Removes and returns the last value in this array. @param arr The array from which the value is to be removed. Returns false if it is NULL or not an array. @return The last value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove_last( yyjson_mut_val *arr); /** Removes all values within a specified range in the array. @param arr The array from which the value is to be removed. Returns false if it is NULL or not an array. @param idx The start index of the range (0 is the first). @param len The number of items in the range (can be 0). @return Whether successful. @warning This function takes a linear search time. */ yyjson_api_inline bool yyjson_mut_arr_remove_range(yyjson_mut_val *arr, size_t idx, size_t len); /** Removes all values in this array. @param arr The array from which all of the values are to be removed. Returns false if it is NULL or not an array. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_clear(yyjson_mut_val *arr); /** Rotates values in this array for the given number of times. For example: `[1,2,3,4,5]` rotate 2 is `[3,4,5,1,2]`. @param arr The array to be rotated. @param idx Index (or times) to rotate. @warning This function takes a linear search time. */ yyjson_api_inline bool yyjson_mut_arr_rotate(yyjson_mut_val *arr, size_t idx); /*============================================================================== * Mutable JSON Array Modification Convenience API *============================================================================*/ /** Adds a value at the end of the array. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param val The value to be inserted. Returns false if it is NULL. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_val(yyjson_mut_val *arr, yyjson_mut_val *val); /** Adds a `null` value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_null(yyjson_mut_doc *doc, yyjson_mut_val *arr); /** Adds a `true` value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_true(yyjson_mut_doc *doc, yyjson_mut_val *arr); /** Adds a `false` value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_false(yyjson_mut_doc *doc, yyjson_mut_val *arr); /** Adds a bool value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param val The bool value to be added. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *arr, bool val); /** Adds an unsigned integer value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param num The number to be added. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *arr, uint64_t num); /** Adds a signed integer value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param num The number to be added. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num); /** Adds a integer value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param num The number to be added. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_int(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num); /** Adds a double value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param num The number to be added. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_real(yyjson_mut_doc *doc, yyjson_mut_val *arr, double num); /** Adds a string value at the end of the array (no copy). @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param str A null-terminated UTF-8 string. @return Whether successful. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_arr_add_str(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str); /** Adds a string value at the end of the array (no copy). @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param str A UTF-8 string, null-terminator is not required. @param len The length of the string, in bytes. @return Whether successful. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_arr_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len); /** Adds a string value at the end of the array (copied). @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param str A null-terminated UTF-8 string. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str); /** Adds a string value at the end of the array (copied). @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @param str A UTF-8 string, null-terminator is not required. @param len The length of the string, in bytes. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_arr_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len); /** Creates and adds a new array at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @return The new array, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *arr); /** Creates and adds a new object at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @return The new object, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *arr); /*============================================================================== * Mutable JSON Object API *============================================================================*/ /** Returns the number of key-value pairs in this object. Returns 0 if `obj` is NULL or type is not object. */ yyjson_api_inline size_t yyjson_mut_obj_size(yyjson_mut_val *obj); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. The `key` should be a null-terminated UTF-8 string. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_get(yyjson_mut_val *obj, const char *key); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. The `key` should be a UTF-8 string, null-terminator is not required. The `key_len` should be the length of the key, in bytes. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_getn(yyjson_mut_val *obj, const char *key, size_t key_len); /*============================================================================== * Mutable JSON Object Iterator API *============================================================================*/ /** A mutable JSON object iterator. @warning You should not modify the object while iterating over it, but you can use `yyjson_mut_obj_iter_remove()` to remove current value. @par Example @code yyjson_mut_val *key, *val; yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj); while ((key = yyjson_mut_obj_iter_next(&iter))) { val = yyjson_mut_obj_iter_get_val(key); your_func(key, val); if (your_val_is_unused(key, val)) { yyjson_mut_obj_iter_remove(&iter); } } @endcode If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups: @code // {"k1":1, "k2": 3, "k3": 3} yyjson_mut_val *key, *val; yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj); yyjson_mut_val *v1 = yyjson_mut_obj_iter_get(&iter, "k1"); yyjson_mut_val *v3 = yyjson_mut_obj_iter_get(&iter, "k3"); @endcode @see `yyjson_mut_obj_iter_get()` and `yyjson_mut_obj_iter_getn()` */ typedef struct yyjson_mut_obj_iter { size_t idx; /**< next key's index */ size_t max; /**< maximum key index (obj.size) */ yyjson_mut_val *cur; /**< current key */ yyjson_mut_val *pre; /**< previous key */ yyjson_mut_val *obj; /**< the object being iterated */ } yyjson_mut_obj_iter; /** Initialize an iterator for this object. @param obj The object to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_mut_obj_iter_init(yyjson_mut_val *obj, yyjson_mut_obj_iter *iter); /** Create an iterator with an object, same as `yyjson_obj_iter_init()`. @param obj The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. @return A new iterator for the object. @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with( yyjson_mut_val *obj); /** Returns whether the iteration has more elements. If `iter` is NULL, this function will return false. */ yyjson_api_inline bool yyjson_mut_obj_iter_has_next( yyjson_mut_obj_iter *iter); /** Returns the next key in the iteration, or NULL on end. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_next( yyjson_mut_obj_iter *iter); /** Returns the value for key inside the iteration. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get_val( yyjson_mut_val *key); /** Removes current key-value pair in the iteration, returns the removed value. If `iter` is NULL, this function will return NULL. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_remove( yyjson_mut_obj_iter *iter); /** Iterates to a specified key and returns the value. This function does the same thing as `yyjson_mut_obj_get()`, but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string with null-terminator. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get( yyjson_mut_obj_iter *iter, const char *key); /** Iterates to a specified key and returns the value. This function does the same thing as `yyjson_mut_obj_getn()` but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string, null-terminator is not required. @param key_len The the length of `key`, in bytes. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_getn( yyjson_mut_obj_iter *iter, const char *key, size_t key_len); /** Macro for iterating over an object. It works like iterator, but with a more intuitive API. @warning You should not modify the object while iterating over it. @par Example @code size_t idx, max; yyjson_val *key, *val; yyjson_obj_foreach(obj, idx, max, key, val) { your_func(key, val); } @endcode */ #define yyjson_mut_obj_foreach(obj, idx, max, key, val) \ for ((idx) = 0, \ (max) = yyjson_mut_obj_size(obj), \ (key) = (max) ? ((yyjson_mut_val *)(obj)->uni.ptr)->next->next : NULL, \ (val) = (key) ? (key)->next : NULL; \ (idx) < (max); \ (idx)++, \ (key) = (val)->next, \ (val) = (key)->next) /*============================================================================== * Mutable JSON Object Creation API *============================================================================*/ /** Creates and returns a mutable object, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj(yyjson_mut_doc *doc); /** Creates and returns a mutable object with keys and values, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. @par Example @code const char *keys[2] = { "id", "name" }; const char *vals[2] = { "01", "Harry" }; yyjson_mut_val *obj = yyjson_mut_obj_with_str(doc, keys, vals, 2); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_with_str(yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count); /** Creates and returns a mutable object with key-value pairs and pair count, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string. @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. @par Example @code const char *kv_pairs[4] = { "id", "01", "name", "Harry" }; yyjson_mut_val *obj = yyjson_mut_obj_with_kv(doc, kv_pairs, 2); @endcode */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_with_kv(yyjson_mut_doc *doc, const char **kv_pairs, size_t pair_count); /*============================================================================== * Mutable JSON Object Modification API *============================================================================*/ /** Adds a key-value pair at the end of the object. This function allows duplicated key in one object. @param obj The object to which the new key-value pair is to be added. @param key The key, should be a string which is created by `yyjson_mut_str()`, `yyjson_mut_strn()`, `yyjson_mut_strcpy()` or `yyjson_mut_strncpy()`. @param val The value to add to the object. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_obj_add(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val); /** Sets a key-value pair at the end of the object. This function may remove all key-value pairs for the given key before add. @param obj The object to which the new key-value pair is to be added. @param key The key, should be a string which is created by `yyjson_mut_str()`, `yyjson_mut_strn()`, `yyjson_mut_strcpy()` or `yyjson_mut_strncpy()`. @param val The value to add to the object. If this value is null, the behavior is same as `yyjson_mut_obj_remove()`. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_obj_put(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val); /** Inserts a key-value pair to the object at the given position. This function allows duplicated key in one object. @param obj The object to which the new key-value pair is to be added. @param key The key, should be a string which is created by `yyjson_mut_str()`, `yyjson_mut_strn()`, `yyjson_mut_strcpy()` or `yyjson_mut_strncpy()`. @param val The value to add to the object. @param idx The index to which to insert the new pair. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_obj_insert(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val, size_t idx); /** Removes all key-value pair from the object with given key. @param obj The object from which the key-value pair is to be removed. @param key The key, should be a string value. @return The first matched value, or NULL if no matched value. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove(yyjson_mut_val *obj, yyjson_mut_val *key); /** Removes all key-value pair from the object with given key. @param obj The object from which the key-value pair is to be removed. @param key The key, should be a UTF-8 string with null-terminator. @return The first matched value, or NULL if no matched value. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_key( yyjson_mut_val *obj, const char *key); /** Removes all key-value pair from the object with given key. @param obj The object from which the key-value pair is to be removed. @param key The key, should be a UTF-8 string, null-terminator is not required. @param key_len The length of the key. @return The first matched value, or NULL if no matched value. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_keyn( yyjson_mut_val *obj, const char *key, size_t key_len); /** Removes all key-value pairs in this object. @param obj The object from which all of the values are to be removed. @return Whether successful. */ yyjson_api_inline bool yyjson_mut_obj_clear(yyjson_mut_val *obj); /** Replaces value from the object with given key. If the key is not exist, or the value is NULL, it will fail. @param obj The object to which the value is to be replaced. @param key The key, should be a string value. @param val The value to replace into the object. @return Whether successful. @warning This function takes a linear search time. */ yyjson_api_inline bool yyjson_mut_obj_replace(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val); /** Rotates key-value pairs in the object for the given number of times. For example: `{"a":1,"b":2,"c":3,"d":4}` rotate 1 is `{"b":2,"c":3,"d":4,"a":1}`. @param obj The object to be rotated. @param idx Index (or times) to rotate. @return Whether successful. @warning This function takes a linear search time. */ yyjson_api_inline bool yyjson_mut_obj_rotate(yyjson_mut_val *obj, size_t idx); /*============================================================================== * Mutable JSON Object Modification Convenience API *============================================================================*/ /** Adds a `null` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key); /** Adds a `true` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key); /** Adds a `false` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key); /** Adds a bool value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, bool val); /** Adds an unsigned integer value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, uint64_t val); /** Adds a signed integer value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val); /** Adds an int value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val); /** Adds a double value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, double val); /** Adds a string value at the end of the object. The `key` and `val` should be null-terminated UTF-8 strings. This function allows duplicated key in one object. @warning The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val); /** Adds a string value at the end of the object. The `key` should be a null-terminated UTF-8 string. The `val` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the `val`, in bytes. This function allows duplicated key in one object. @warning The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len); /** Adds a string value at the end of the object. The `key` and `val` should be null-terminated UTF-8 strings. The value string is copied. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val); /** Adds a string value at the end of the object. The `key` should be a null-terminated UTF-8 string. The `val` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the `val`, in bytes. This function allows duplicated key in one object. @warning The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len); /** Creates and adds a new array to the target object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. @return The new array, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key); /** Creates and adds a new object to the target object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. @return The new object, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key); /** Adds a JSON value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, yyjson_mut_val *val); /** Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The `key` should be a null-terminated UTF-8 string. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_str( yyjson_mut_val *obj, const char *key); /** Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The `key` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the key, in bytes. @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_strn( yyjson_mut_val *obj, const char *key, size_t len); /** Replaces all matching keys with the new key. Returns true if at least one key was renamed. The `key` and `new_key` should be a null-terminated UTF-8 string. The `new_key` is copied and held by doc. @warning This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys. */ yyjson_api_inline bool yyjson_mut_obj_rename_key(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *new_key); /** Replaces all matching keys with the new key. Returns true if at least one key was renamed. The `key` and `new_key` should be a UTF-8 string, null-terminator is not required. The `new_key` is copied and held by doc. @warning This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys. */ yyjson_api_inline bool yyjson_mut_obj_rename_keyn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, size_t len, const char *new_key, size_t new_len); /*============================================================================== * JSON Pointer API (RFC 6901) * https://tools.ietf.org/html/rfc6901 *============================================================================*/ /** JSON Pointer error code. */ typedef uint32_t yyjson_ptr_code; /** No JSON pointer error. */ static const yyjson_ptr_code YYJSON_PTR_ERR_NONE = 0; /** Invalid input parameter, such as NULL input. */ static const yyjson_ptr_code YYJSON_PTR_ERR_PARAMETER = 1; /** JSON pointer syntax error, such as invalid escape, token no prefix. */ static const yyjson_ptr_code YYJSON_PTR_ERR_SYNTAX = 2; /** JSON pointer resolve failed, such as index out of range, key not found. */ static const yyjson_ptr_code YYJSON_PTR_ERR_RESOLVE = 3; /** Document's root is NULL, but it is required for the function call. */ static const yyjson_ptr_code YYJSON_PTR_ERR_NULL_ROOT = 4; /** Cannot set root as the target is not a document. */ static const yyjson_ptr_code YYJSON_PTR_ERR_SET_ROOT = 5; /** The memory allocation failed and a new value could not be created. */ static const yyjson_ptr_code YYJSON_PTR_ERR_MEMORY_ALLOCATION = 6; /** Error information for JSON pointer. */ typedef struct yyjson_ptr_err { /** Error code, see `yyjson_ptr_code` for all possible values. */ yyjson_ptr_code code; /** Error message, constant, no need to free (NULL if no error). */ const char *msg; /** Error byte position for input JSON pointer (0 if no error). */ size_t pos; } yyjson_ptr_err; /** A context for JSON pointer operation. This struct stores the context of JSON Pointer operation result. The struct can be used with three helper functions: `ctx_append()`, `ctx_replace()`, and `ctx_remove()`, which perform the corresponding operations on the container without re-parsing the JSON Pointer. For example: @code // doc before: {"a":[0,1,null]} // ptr: "/a/2" val = yyjson_mut_doc_ptr_getx(doc, ptr, strlen(ptr), &ctx, &err); if (yyjson_is_null(val)) { yyjson_ptr_ctx_remove(&ctx); } // doc after: {"a":[0,1]} @endcode */ typedef struct yyjson_ptr_ctx { /** The container (parent) of the target value. It can be either an array or an object. If the target location has no value, but all its parent containers exist, and the target location can be used to insert a new value, then `ctn` is the parent container of the target location. Otherwise, `ctn` is NULL. */ yyjson_mut_val *ctn; /** The previous sibling of the target value. It can be either a value in an array or a key in an object. As the container is a `circular linked list` of elements, `pre` is the previous node of the target value. If the operation is `add` or `set`, then `pre` is the previous node of the new value, not the original target value. If the target value does not exist, `pre` is NULL. */ yyjson_mut_val *pre; /** The removed value if the operation is `set`, `replace` or `remove`. It can be used to restore the original state of the document if needed. */ yyjson_mut_val *old; } yyjson_ptr_ctx; /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_doc_ptr_get(yyjson_doc *doc, const char *ptr); /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_doc_ptr_getn(yyjson_doc *doc, const char *ptr, size_t len); /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param err A pointer to store the error information, or NULL if not needed. @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_doc_ptr_getx(yyjson_doc *doc, const char *ptr, size_t len, yyjson_ptr_err *err); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_ptr_get(yyjson_val *val, const char *ptr); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_ptr_getn(yyjson_val *val, const char *ptr, size_t len); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param err A pointer to store the error information, or NULL if not needed. @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_val *yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err); /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_get(yyjson_mut_doc *doc, const char *ptr); /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_getn(yyjson_mut_doc *doc, const char *ptr, size_t len); /** Get value by a JSON Pointer. @param doc The JSON document to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_getx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_get(yyjson_mut_val *val, const char *ptr); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_getn(yyjson_mut_val *val, const char *ptr, size_t len); /** Get value by a JSON Pointer. @param val The JSON value to be queried. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_getx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Add (insert) value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param new_val The value to be added. @return true if JSON pointer is valid and new value is added, false otherwise. @note The parent nodes will be created if they do not exist. */ yyjson_api_inline bool yyjson_mut_doc_ptr_add(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val); /** Add (insert) value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be added. @return true if JSON pointer is valid and new value is added, false otherwise. @note The parent nodes will be created if they do not exist. */ yyjson_api_inline bool yyjson_mut_doc_ptr_addn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val); /** Add (insert) value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be added. @param create_parent Whether to create parent nodes if not exist. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return true if JSON pointer is valid and new value is added, false otherwise. */ yyjson_api_inline bool yyjson_mut_doc_ptr_addx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Add (insert) value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param doc Only used to create new values when needed. @param new_val The value to be added. @return true if JSON pointer is valid and new value is added, false otherwise. @note The parent nodes will be created if they do not exist. */ yyjson_api_inline bool yyjson_mut_ptr_add(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc); /** Add (insert) value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param doc Only used to create new values when needed. @param new_val The value to be added. @return true if JSON pointer is valid and new value is added, false otherwise. @note The parent nodes will be created if they do not exist. */ yyjson_api_inline bool yyjson_mut_ptr_addn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc); /** Add (insert) value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param doc Only used to create new values when needed. @param new_val The value to be added. @param create_parent Whether to create parent nodes if not exist. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return true if JSON pointer is valid and new value is added, false otherwise. */ yyjson_api_inline bool yyjson_mut_ptr_addx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Set value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param new_val The value to be set, pass NULL to remove. @return true if JSON pointer is valid and new value is set, false otherwise. @note The parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_doc_ptr_set(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val); /** Set value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be set, pass NULL to remove. @return true if JSON pointer is valid and new value is set, false otherwise. @note The parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_doc_ptr_setn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val); /** Set value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be set, pass NULL to remove. @param create_parent Whether to create parent nodes if not exist. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return true if JSON pointer is valid and new value is set, false otherwise. @note If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_doc_ptr_setx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Set value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param new_val The value to be set, pass NULL to remove. @param doc Only used to create new values when needed. @return true if JSON pointer is valid and new value is set, false otherwise. @note The parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_ptr_set(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc); /** Set value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be set, pass NULL to remove. @param doc Only used to create new values when needed. @return true if JSON pointer is valid and new value is set, false otherwise. @note The parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_ptr_setn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc); /** Set value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The value to be set, pass NULL to remove. @param doc Only used to create new values when needed. @param create_parent Whether to create parent nodes if not exist. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return true if JSON pointer is valid and new value is set, false otherwise. @note If the target value already exists, it will be replaced by the new value. */ yyjson_api_inline bool yyjson_mut_ptr_setx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Replace value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param new_val The new value to replace the old one. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replace( yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val); /** Replace value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The new value to replace the old one. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacen( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val); /** Replace value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The new value to replace the old one. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Replace value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8 with null-terminator). @param new_val The new value to replace the old one. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replace( yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val); /** Replace value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The new value to replace the old one. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacen( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val); /** Replace value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param new_val The new value to replace the old one. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The old value that was replaced, or NULL if not found. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Remove value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_remove( yyjson_mut_doc *doc, const char *ptr); /** Remove value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removen( yyjson_mut_doc *doc, const char *ptr, size_t len); /** Remove value by a JSON pointer. @param doc The target JSON document. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Remove value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8 with null-terminator). @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_remove(yyjson_mut_val *val, const char *ptr); /** Remove value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_removen(yyjson_mut_val *val, const char *ptr, size_t len); /** Remove value by a JSON pointer. @param val The target JSON value. @param ptr The JSON pointer string (UTF-8, null-terminator is not required). @param len The length of `ptr` in bytes. @param ctx A pointer to store the result context, or NULL if not needed. @param err A pointer to store the error information, or NULL if not needed. @return The removed value, or NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /** Append value by JSON pointer context. @param ctx The context from the `yyjson_mut_ptr_xxx()` calls. @param key New key if `ctx->ctn` is object, or NULL if `ctx->ctn` is array. @param val New value to be added. @return true on success or false on fail. */ yyjson_api_inline bool yyjson_ptr_ctx_append(yyjson_ptr_ctx *ctx, yyjson_mut_val *key, yyjson_mut_val *val); /** Replace value by JSON pointer context. @param ctx The context from the `yyjson_mut_ptr_xxx()` calls. @param val New value to be replaced. @return true on success or false on fail. @note If success, the old value will be returned via `ctx->old`. */ yyjson_api_inline bool yyjson_ptr_ctx_replace(yyjson_ptr_ctx *ctx, yyjson_mut_val *val); /** Remove value by JSON pointer context. @param ctx The context from the `yyjson_mut_ptr_xxx()` calls. @return true on success or false on fail. @note If success, the old value will be returned via `ctx->old`. */ yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx); /*============================================================================== * JSON Patch API (RFC 6902) * https://tools.ietf.org/html/rfc6902 *============================================================================*/ /** Result code for JSON patch. */ typedef uint32_t yyjson_patch_code; /** Success, no error. */ static const yyjson_patch_code YYJSON_PATCH_SUCCESS = 0; /** Invalid parameter, such as NULL input or non-array patch. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_PARAMETER = 1; /** Memory allocation failure occurs. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_MEMORY_ALLOCATION = 2; /** JSON patch operation is not object type. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_OPERATION = 3; /** JSON patch operation is missing a required key. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_MISSING_KEY = 4; /** JSON patch operation member is invalid. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_MEMBER = 5; /** JSON patch operation `test` not equal. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_EQUAL = 6; /** JSON patch operation failed on JSON pointer. */ static const yyjson_patch_code YYJSON_PATCH_ERROR_POINTER = 7; /** Error information for JSON patch. */ typedef struct yyjson_patch_err { /** Error code, see `yyjson_patch_code` for all possible values. */ yyjson_patch_code code; /** Index of the error operation (0 if no error). */ size_t idx; /** Error message, constant, no need to free (NULL if no error). */ const char *msg; /** JSON pointer error if `code == YYJSON_PATCH_ERROR_POINTER`. */ yyjson_ptr_err ptr; } yyjson_patch_err; /** Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the `doc`. The `err` is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied. */ yyjson_api yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch, yyjson_patch_err *err); /** Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the `doc`. The `err` is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied. */ yyjson_api yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch, yyjson_patch_err *err); /*============================================================================== * JSON Merge-Patch API (RFC 7386) * https://tools.ietf.org/html/rfc7386 *============================================================================*/ /** Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the `doc`. Returns NULL if the patch could not be applied. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api yyjson_mut_val *yyjson_merge_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch); /** Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the `doc`. Returns NULL if the patch could not be applied. @warning This function is recursive and may cause a stack overflow if the object level is too deep. */ yyjson_api yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch); /*============================================================================== * JSON Structure (Implementation) *============================================================================*/ /** Payload of a JSON value (8 bytes). */ typedef union yyjson_val_uni { uint64_t u64; int64_t i64; double f64; const char *str; void *ptr; size_t ofs; } yyjson_val_uni; /** Immutable JSON value, 16 bytes. */ struct yyjson_val { uint64_t tag; /**< type, subtype and length */ yyjson_val_uni uni; /**< payload */ }; struct yyjson_doc { /** Root value of the document (nonnull). */ yyjson_val *root; /** Allocator used by document (nonnull). */ yyjson_alc alc; /** The total number of bytes read when parsing JSON (nonzero). */ size_t dat_read; /** The total number of value read when parsing JSON (nonzero). */ size_t val_read; /** The string pool used by JSON values (nullable). */ char *str_pool; }; /*============================================================================== * Unsafe JSON Value API (Implementation) *============================================================================*/ /* Whether the string does not need to be escaped for serialization. This function is used to optimize the writing speed of small constant strings. This function works only if the compiler can evaluate it at compile time. Clang supports it since v8.0, earlier versions do not support constant_p(strlen) and return false. GCC supports it since at least v4.4, earlier versions may compile it as run-time instructions. ICC supports it since at least v16, earlier versions are uncertain. @param str The C string. @param len The returnd value from strlen(str). */ yyjson_api_inline bool unsafe_yyjson_is_str_noesc(const char *str, size_t len) { #if YYJSON_HAS_CONSTANT_P && \ (!YYJSON_IS_REAL_GCC || yyjson_gcc_available(4, 4, 0)) if (yyjson_constant_p(len) && len <= 32) { /* Same as the following loop: for (size_t i = 0; i < len; i++) { char c = str[i]; if (c < ' ' || c > '~' || c == '"' || c == '\\') return false; } GCC evaluates it at compile time only if the string length is within 17 and -O3 (which turns on the -fpeel-loops flag) is used. So the loop is unrolled for GCC. */ # define yyjson_repeat32_incr(x) \ x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) \ x(8) x(9) x(10) x(11) x(12) x(13) x(14) x(15) \ x(16) x(17) x(18) x(19) x(20) x(21) x(22) x(23) \ x(24) x(25) x(26) x(27) x(28) x(29) x(30) x(31) # define yyjson_check_char_noesc(i) \ if (i < len) { \ char c = str[i]; \ if (c < ' ' || c > '~' || c == '"' || c == '\\') return false; } yyjson_repeat32_incr(yyjson_check_char_noesc) # undef yyjson_repeat32_incr # undef yyjson_check_char_noesc return true; } #else (void)str; (void)len; #endif return false; } yyjson_api_inline yyjson_type unsafe_yyjson_get_type(void *val) { uint8_t tag = (uint8_t)((yyjson_val *)val)->tag; return (yyjson_type)(tag & YYJSON_TYPE_MASK); } yyjson_api_inline yyjson_subtype unsafe_yyjson_get_subtype(void *val) { uint8_t tag = (uint8_t)((yyjson_val *)val)->tag; return (yyjson_subtype)(tag & YYJSON_SUBTYPE_MASK); } yyjson_api_inline uint8_t unsafe_yyjson_get_tag(void *val) { uint8_t tag = (uint8_t)((yyjson_val *)val)->tag; return (uint8_t)(tag & YYJSON_TAG_MASK); } yyjson_api_inline bool unsafe_yyjson_is_raw(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_RAW; } yyjson_api_inline bool unsafe_yyjson_is_null(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_NULL; } yyjson_api_inline bool unsafe_yyjson_is_bool(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_BOOL; } yyjson_api_inline bool unsafe_yyjson_is_num(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_NUM; } yyjson_api_inline bool unsafe_yyjson_is_str(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_STR; } yyjson_api_inline bool unsafe_yyjson_is_arr(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_ARR; } yyjson_api_inline bool unsafe_yyjson_is_obj(void *val) { return unsafe_yyjson_get_type(val) == YYJSON_TYPE_OBJ; } yyjson_api_inline bool unsafe_yyjson_is_ctn(void *val) { uint8_t mask = YYJSON_TYPE_ARR & YYJSON_TYPE_OBJ; return (unsafe_yyjson_get_tag(val) & mask) == mask; } yyjson_api_inline bool unsafe_yyjson_is_uint(void *val) { const uint8_t patt = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; return unsafe_yyjson_get_tag(val) == patt; } yyjson_api_inline bool unsafe_yyjson_is_sint(void *val) { const uint8_t patt = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; return unsafe_yyjson_get_tag(val) == patt; } yyjson_api_inline bool unsafe_yyjson_is_int(void *val) { const uint8_t mask = YYJSON_TAG_MASK & (~YYJSON_SUBTYPE_SINT); const uint8_t patt = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; return (unsafe_yyjson_get_tag(val) & mask) == patt; } yyjson_api_inline bool unsafe_yyjson_is_real(void *val) { const uint8_t patt = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; return unsafe_yyjson_get_tag(val) == patt; } yyjson_api_inline bool unsafe_yyjson_is_true(void *val) { const uint8_t patt = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; return unsafe_yyjson_get_tag(val) == patt; } yyjson_api_inline bool unsafe_yyjson_is_false(void *val) { const uint8_t patt = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; return unsafe_yyjson_get_tag(val) == patt; } yyjson_api_inline bool unsafe_yyjson_arr_is_flat(yyjson_val *val) { size_t ofs = val->uni.ofs; size_t len = (size_t)(val->tag >> YYJSON_TAG_BIT); return len * sizeof(yyjson_val) + sizeof(yyjson_val) == ofs; } yyjson_api_inline const char *unsafe_yyjson_get_raw(void *val) { return ((yyjson_val *)val)->uni.str; } yyjson_api_inline bool unsafe_yyjson_get_bool(void *val) { uint8_t tag = unsafe_yyjson_get_tag(val); return (bool)((tag & YYJSON_SUBTYPE_MASK) >> YYJSON_TYPE_BIT); } yyjson_api_inline uint64_t unsafe_yyjson_get_uint(void *val) { return ((yyjson_val *)val)->uni.u64; } yyjson_api_inline int64_t unsafe_yyjson_get_sint(void *val) { return ((yyjson_val *)val)->uni.i64; } yyjson_api_inline int unsafe_yyjson_get_int(void *val) { return (int)((yyjson_val *)val)->uni.i64; } yyjson_api_inline double unsafe_yyjson_get_real(void *val) { return ((yyjson_val *)val)->uni.f64; } yyjson_api_inline double unsafe_yyjson_get_num(void *val) { uint8_t tag = unsafe_yyjson_get_tag(val); if (tag == (YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL)) { return ((yyjson_val *)val)->uni.f64; } else if (tag == (YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT)) { return (double)((yyjson_val *)val)->uni.i64; } else if (tag == (YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT)) { #if YYJSON_U64_TO_F64_NO_IMPL uint64_t msb = ((uint64_t)1) << 63; uint64_t num = ((yyjson_val *)val)->uni.u64; if ((num & msb) == 0) { return (double)(int64_t)num; } else { return ((double)(int64_t)((num >> 1) | (num & 1))) * (double)2.0; } #else return (double)((yyjson_val *)val)->uni.u64; #endif } return 0.0; } yyjson_api_inline const char *unsafe_yyjson_get_str(void *val) { return ((yyjson_val *)val)->uni.str; } yyjson_api_inline size_t unsafe_yyjson_get_len(void *val) { return (size_t)(((yyjson_val *)val)->tag >> YYJSON_TAG_BIT); } yyjson_api_inline yyjson_val *unsafe_yyjson_get_first(yyjson_val *ctn) { return ctn + 1; } yyjson_api_inline yyjson_val *unsafe_yyjson_get_next(yyjson_val *val) { bool is_ctn = unsafe_yyjson_is_ctn(val); size_t ctn_ofs = val->uni.ofs; size_t ofs = (is_ctn ? ctn_ofs : sizeof(yyjson_val)); return (yyjson_val *)(void *)((uint8_t *)val + ofs); } yyjson_api_inline bool unsafe_yyjson_equals_strn(void *val, const char *str, size_t len) { return unsafe_yyjson_get_len(val) == len && memcmp(((yyjson_val *)val)->uni.str, str, len) == 0; } yyjson_api_inline bool unsafe_yyjson_equals_str(void *val, const char *str) { return unsafe_yyjson_equals_strn(val, str, strlen(str)); } yyjson_api_inline void unsafe_yyjson_set_type(void *val, yyjson_type type, yyjson_subtype subtype) { uint8_t tag = (type | subtype); uint64_t new_tag = ((yyjson_val *)val)->tag; new_tag = (new_tag & (~(uint64_t)YYJSON_TAG_MASK)) | (uint64_t)tag; ((yyjson_val *)val)->tag = new_tag; } yyjson_api_inline void unsafe_yyjson_set_len(void *val, size_t len) { uint64_t tag = ((yyjson_val *)val)->tag & YYJSON_TAG_MASK; tag |= (uint64_t)len << YYJSON_TAG_BIT; ((yyjson_val *)val)->tag = tag; } yyjson_api_inline void unsafe_yyjson_inc_len(void *val) { uint64_t tag = ((yyjson_val *)val)->tag; tag += (uint64_t)(1 << YYJSON_TAG_BIT); ((yyjson_val *)val)->tag = tag; } yyjson_api_inline void unsafe_yyjson_set_raw(void *val, const char *raw, size_t len) { unsafe_yyjson_set_type(val, YYJSON_TYPE_RAW, YYJSON_SUBTYPE_NONE); unsafe_yyjson_set_len(val, len); ((yyjson_val *)val)->uni.str = raw; } yyjson_api_inline void unsafe_yyjson_set_null(void *val) { unsafe_yyjson_set_type(val, YYJSON_TYPE_NULL, YYJSON_SUBTYPE_NONE); unsafe_yyjson_set_len(val, 0); } yyjson_api_inline void unsafe_yyjson_set_bool(void *val, bool num) { yyjson_subtype subtype = num ? YYJSON_SUBTYPE_TRUE : YYJSON_SUBTYPE_FALSE; unsafe_yyjson_set_type(val, YYJSON_TYPE_BOOL, subtype); unsafe_yyjson_set_len(val, 0); } yyjson_api_inline void unsafe_yyjson_set_uint(void *val, uint64_t num) { unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_UINT); unsafe_yyjson_set_len(val, 0); ((yyjson_val *)val)->uni.u64 = num; } yyjson_api_inline void unsafe_yyjson_set_sint(void *val, int64_t num) { unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_SINT); unsafe_yyjson_set_len(val, 0); ((yyjson_val *)val)->uni.i64 = num; } yyjson_api_inline void unsafe_yyjson_set_real(void *val, double num) { unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL); unsafe_yyjson_set_len(val, 0); ((yyjson_val *)val)->uni.f64 = num; } yyjson_api_inline void unsafe_yyjson_set_str(void *val, const char *str) { size_t len = strlen(str); bool noesc = unsafe_yyjson_is_str_noesc(str, len); yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; unsafe_yyjson_set_type(val, YYJSON_TYPE_STR, sub); unsafe_yyjson_set_len(val, len); ((yyjson_val *)val)->uni.str = str; } yyjson_api_inline void unsafe_yyjson_set_strn(void *val, const char *str, size_t len) { unsafe_yyjson_set_type(val, YYJSON_TYPE_STR, YYJSON_SUBTYPE_NONE); unsafe_yyjson_set_len(val, len); ((yyjson_val *)val)->uni.str = str; } yyjson_api_inline void unsafe_yyjson_set_arr(void *val, size_t size) { unsafe_yyjson_set_type(val, YYJSON_TYPE_ARR, YYJSON_SUBTYPE_NONE); unsafe_yyjson_set_len(val, size); } yyjson_api_inline void unsafe_yyjson_set_obj(void *val, size_t size) { unsafe_yyjson_set_type(val, YYJSON_TYPE_OBJ, YYJSON_SUBTYPE_NONE); unsafe_yyjson_set_len(val, size); } /*============================================================================== * JSON Document API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_val *yyjson_doc_get_root(yyjson_doc *doc) { return doc ? doc->root : NULL; } yyjson_api_inline size_t yyjson_doc_get_read_size(yyjson_doc *doc) { return doc ? doc->dat_read : 0; } yyjson_api_inline size_t yyjson_doc_get_val_count(yyjson_doc *doc) { return doc ? doc->val_read : 0; } yyjson_api void yyjson_doc_free(yyjson_doc *doc) { if (doc) { yyjson_alc alc = doc->alc; memset(&doc->alc, 0, sizeof(alc)); if (doc->str_pool) alc.free(alc.ctx, doc->str_pool); alc.free(alc.ctx, doc); } } /*============================================================================== * JSON Value Type API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_is_raw(yyjson_val *val) { return val ? unsafe_yyjson_is_raw(val) : false; } yyjson_api_inline bool yyjson_is_null(yyjson_val *val) { return val ? unsafe_yyjson_is_null(val) : false; } yyjson_api_inline bool yyjson_is_true(yyjson_val *val) { return val ? unsafe_yyjson_is_true(val) : false; } yyjson_api_inline bool yyjson_is_false(yyjson_val *val) { return val ? unsafe_yyjson_is_false(val) : false; } yyjson_api_inline bool yyjson_is_bool(yyjson_val *val) { return val ? unsafe_yyjson_is_bool(val) : false; } yyjson_api_inline bool yyjson_is_uint(yyjson_val *val) { return val ? unsafe_yyjson_is_uint(val) : false; } yyjson_api_inline bool yyjson_is_sint(yyjson_val *val) { return val ? unsafe_yyjson_is_sint(val) : false; } yyjson_api_inline bool yyjson_is_int(yyjson_val *val) { return val ? unsafe_yyjson_is_int(val) : false; } yyjson_api_inline bool yyjson_is_real(yyjson_val *val) { return val ? unsafe_yyjson_is_real(val) : false; } yyjson_api_inline bool yyjson_is_num(yyjson_val *val) { return val ? unsafe_yyjson_is_num(val) : false; } yyjson_api_inline bool yyjson_is_str(yyjson_val *val) { return val ? unsafe_yyjson_is_str(val) : false; } yyjson_api_inline bool yyjson_is_arr(yyjson_val *val) { return val ? unsafe_yyjson_is_arr(val) : false; } yyjson_api_inline bool yyjson_is_obj(yyjson_val *val) { return val ? unsafe_yyjson_is_obj(val) : false; } yyjson_api_inline bool yyjson_is_ctn(yyjson_val *val) { return val ? unsafe_yyjson_is_ctn(val) : false; } /*============================================================================== * JSON Value Content API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_type yyjson_get_type(yyjson_val *val) { return val ? unsafe_yyjson_get_type(val) : YYJSON_TYPE_NONE; } yyjson_api_inline yyjson_subtype yyjson_get_subtype(yyjson_val *val) { return val ? unsafe_yyjson_get_subtype(val) : YYJSON_SUBTYPE_NONE; } yyjson_api_inline uint8_t yyjson_get_tag(yyjson_val *val) { return val ? unsafe_yyjson_get_tag(val) : 0; } yyjson_api_inline const char *yyjson_get_type_desc(yyjson_val *val) { switch (yyjson_get_tag(val)) { case YYJSON_TYPE_RAW | YYJSON_SUBTYPE_NONE: return "raw"; case YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE: return "null"; case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NONE: return "string"; case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NOESC: return "string"; case YYJSON_TYPE_ARR | YYJSON_SUBTYPE_NONE: return "array"; case YYJSON_TYPE_OBJ | YYJSON_SUBTYPE_NONE: return "object"; case YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE: return "true"; case YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE: return "false"; case YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT: return "uint"; case YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT: return "sint"; case YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL: return "real"; default: return "unknown"; } } yyjson_api_inline const char *yyjson_get_raw(yyjson_val *val) { return yyjson_is_raw(val) ? unsafe_yyjson_get_raw(val) : NULL; } yyjson_api_inline bool yyjson_get_bool(yyjson_val *val) { return yyjson_is_bool(val) ? unsafe_yyjson_get_bool(val) : false; } yyjson_api_inline uint64_t yyjson_get_uint(yyjson_val *val) { return yyjson_is_int(val) ? unsafe_yyjson_get_uint(val) : 0; } yyjson_api_inline int64_t yyjson_get_sint(yyjson_val *val) { return yyjson_is_int(val) ? unsafe_yyjson_get_sint(val) : 0; } yyjson_api_inline int yyjson_get_int(yyjson_val *val) { return yyjson_is_int(val) ? unsafe_yyjson_get_int(val) : 0; } yyjson_api_inline double yyjson_get_real(yyjson_val *val) { return yyjson_is_real(val) ? unsafe_yyjson_get_real(val) : 0.0; } yyjson_api_inline double yyjson_get_num(yyjson_val *val) { return val ? unsafe_yyjson_get_num(val) : 0.0; } yyjson_api_inline const char *yyjson_get_str(yyjson_val *val) { return yyjson_is_str(val) ? unsafe_yyjson_get_str(val) : NULL; } yyjson_api_inline size_t yyjson_get_len(yyjson_val *val) { return val ? unsafe_yyjson_get_len(val) : 0; } yyjson_api_inline bool yyjson_equals_str(yyjson_val *val, const char *str) { if (yyjson_likely(val && str)) { return unsafe_yyjson_is_str(val) && unsafe_yyjson_equals_str(val, str); } return false; } yyjson_api_inline bool yyjson_equals_strn(yyjson_val *val, const char *str, size_t len) { if (yyjson_likely(val && str)) { return unsafe_yyjson_is_str(val) && unsafe_yyjson_equals_strn(val, str, len); } return false; } yyjson_api bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs); yyjson_api_inline bool yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { if (yyjson_unlikely(!lhs || !rhs)) return false; return unsafe_yyjson_equals(lhs, rhs); } yyjson_api_inline bool yyjson_set_raw(yyjson_val *val, const char *raw, size_t len) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_raw(val, raw, len); return true; } yyjson_api_inline bool yyjson_set_null(yyjson_val *val) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_null(val); return true; } yyjson_api_inline bool yyjson_set_bool(yyjson_val *val, bool num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_bool(val, num); return true; } yyjson_api_inline bool yyjson_set_uint(yyjson_val *val, uint64_t num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_uint(val, num); return true; } yyjson_api_inline bool yyjson_set_sint(yyjson_val *val, int64_t num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_sint(val, num); return true; } yyjson_api_inline bool yyjson_set_int(yyjson_val *val, int num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_sint(val, (int64_t)num); return true; } yyjson_api_inline bool yyjson_set_real(yyjson_val *val, double num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_real(val, num); return true; } yyjson_api_inline bool yyjson_set_str(yyjson_val *val, const char *str) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; if (yyjson_unlikely(!str)) return false; unsafe_yyjson_set_str(val, str); return true; } yyjson_api_inline bool yyjson_set_strn(yyjson_val *val, const char *str, size_t len) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; if (yyjson_unlikely(!str)) return false; unsafe_yyjson_set_strn(val, str, len); return true; } /*============================================================================== * JSON Array API (Implementation) *============================================================================*/ yyjson_api_inline size_t yyjson_arr_size(yyjson_val *arr) { return yyjson_is_arr(arr) ? unsafe_yyjson_get_len(arr) : 0; } yyjson_api_inline yyjson_val *yyjson_arr_get(yyjson_val *arr, size_t idx) { if (yyjson_likely(yyjson_is_arr(arr))) { if (yyjson_likely(unsafe_yyjson_get_len(arr) > idx)) { yyjson_val *val = unsafe_yyjson_get_first(arr); if (unsafe_yyjson_arr_is_flat(arr)) { return val + idx; } else { while (idx-- > 0) val = unsafe_yyjson_get_next(val); return val; } } } return NULL; } yyjson_api_inline yyjson_val *yyjson_arr_get_first(yyjson_val *arr) { if (yyjson_likely(yyjson_is_arr(arr))) { if (yyjson_likely(unsafe_yyjson_get_len(arr) > 0)) { return unsafe_yyjson_get_first(arr); } } return NULL; } yyjson_api_inline yyjson_val *yyjson_arr_get_last(yyjson_val *arr) { if (yyjson_likely(yyjson_is_arr(arr))) { size_t len = unsafe_yyjson_get_len(arr); if (yyjson_likely(len > 0)) { yyjson_val *val = unsafe_yyjson_get_first(arr); if (unsafe_yyjson_arr_is_flat(arr)) { return val + (len - 1); } else { while (len-- > 1) val = unsafe_yyjson_get_next(val); return val; } } } return NULL; } /*============================================================================== * JSON Array Iterator API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_arr_iter_init(yyjson_val *arr, yyjson_arr_iter *iter) { if (yyjson_likely(yyjson_is_arr(arr) && iter)) { iter->idx = 0; iter->max = unsafe_yyjson_get_len(arr); iter->cur = unsafe_yyjson_get_first(arr); return true; } if (iter) memset(iter, 0, sizeof(yyjson_arr_iter)); return false; } yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr) { yyjson_arr_iter iter; yyjson_arr_iter_init(arr, &iter); return iter; } yyjson_api_inline bool yyjson_arr_iter_has_next(yyjson_arr_iter *iter) { return iter ? iter->idx < iter->max : false; } yyjson_api_inline yyjson_val *yyjson_arr_iter_next(yyjson_arr_iter *iter) { yyjson_val *val; if (iter && iter->idx < iter->max) { val = iter->cur; iter->cur = unsafe_yyjson_get_next(val); iter->idx++; return val; } return NULL; } /*============================================================================== * JSON Object API (Implementation) *============================================================================*/ yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj) { return yyjson_is_obj(obj) ? unsafe_yyjson_get_len(obj) : 0; } yyjson_api_inline yyjson_val *yyjson_obj_get(yyjson_val *obj, const char *key) { return yyjson_obj_getn(obj, key, key ? strlen(key) : 0); } yyjson_api_inline yyjson_val *yyjson_obj_getn(yyjson_val *obj, const char *_key, size_t key_len) { if (yyjson_likely(yyjson_is_obj(obj) && _key)) { size_t len = unsafe_yyjson_get_len(obj); yyjson_val *key = unsafe_yyjson_get_first(obj); while (len-- > 0) { if (unsafe_yyjson_equals_strn(key, _key, key_len)) return key + 1; key = unsafe_yyjson_get_next(key + 1); } } return NULL; } /*============================================================================== * JSON Object Iterator API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_obj_iter_init(yyjson_val *obj, yyjson_obj_iter *iter) { if (yyjson_likely(yyjson_is_obj(obj) && iter)) { iter->idx = 0; iter->max = unsafe_yyjson_get_len(obj); iter->cur = unsafe_yyjson_get_first(obj); iter->obj = obj; return true; } if (iter) memset(iter, 0, sizeof(yyjson_obj_iter)); return false; } yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj) { yyjson_obj_iter iter; yyjson_obj_iter_init(obj, &iter); return iter; } yyjson_api_inline bool yyjson_obj_iter_has_next(yyjson_obj_iter *iter) { return iter ? iter->idx < iter->max : false; } yyjson_api_inline yyjson_val *yyjson_obj_iter_next(yyjson_obj_iter *iter) { if (iter && iter->idx < iter->max) { yyjson_val *key = iter->cur; iter->idx++; iter->cur = unsafe_yyjson_get_next(key + 1); return key; } return NULL; } yyjson_api_inline yyjson_val *yyjson_obj_iter_get_val(yyjson_val *key) { return key ? key + 1 : NULL; } yyjson_api_inline yyjson_val *yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key) { return yyjson_obj_iter_getn(iter, key, key ? strlen(key) : 0); } yyjson_api_inline yyjson_val *yyjson_obj_iter_getn(yyjson_obj_iter *iter, const char *key, size_t key_len) { if (iter && key) { size_t idx = iter->idx; size_t max = iter->max; yyjson_val *cur = iter->cur; if (yyjson_unlikely(idx == max)) { idx = 0; cur = unsafe_yyjson_get_first(iter->obj); } while (idx++ < max) { yyjson_val *next = unsafe_yyjson_get_next(cur + 1); if (unsafe_yyjson_equals_strn(cur, key, key_len)) { iter->idx = idx; iter->cur = next; return cur + 1; } cur = next; if (idx == iter->max && iter->idx < iter->max) { idx = 0; max = iter->idx; cur = unsafe_yyjson_get_first(iter->obj); } } } return NULL; } /*============================================================================== * Mutable JSON Structure (Implementation) *============================================================================*/ /** Mutable JSON value, 24 bytes. The 'tag' and 'uni' field is same as immutable value. The 'next' field links all elements inside the container to be a cycle. */ struct yyjson_mut_val { uint64_t tag; /**< type, subtype and length */ yyjson_val_uni uni; /**< payload */ yyjson_mut_val *next; /**< the next value in circular linked list */ }; /** A memory chunk in string memory pool. */ typedef struct yyjson_str_chunk { struct yyjson_str_chunk *next; /* next chunk linked list */ size_t chunk_size; /* chunk size in bytes */ /* char str[]; flexible array member */ } yyjson_str_chunk; /** A memory pool to hold all strings in a mutable document. */ typedef struct yyjson_str_pool { char *cur; /* cursor inside current chunk */ char *end; /* the end of current chunk */ size_t chunk_size; /* chunk size in bytes while creating new chunk */ size_t chunk_size_max; /* maximum chunk size in bytes */ yyjson_str_chunk *chunks; /* a linked list of chunks, nullable */ } yyjson_str_pool; /** A memory chunk in value memory pool. `sizeof(yyjson_val_chunk)` should not larger than `sizeof(yyjson_mut_val)`. */ typedef struct yyjson_val_chunk { struct yyjson_val_chunk *next; /* next chunk linked list */ size_t chunk_size; /* chunk size in bytes */ /* char pad[sizeof(yyjson_mut_val) - sizeof(yyjson_val_chunk)]; padding */ /* yyjson_mut_val vals[]; flexible array member */ } yyjson_val_chunk; /** A memory pool to hold all values in a mutable document. */ typedef struct yyjson_val_pool { yyjson_mut_val *cur; /* cursor inside current chunk */ yyjson_mut_val *end; /* the end of current chunk */ size_t chunk_size; /* chunk size in bytes while creating new chunk */ size_t chunk_size_max; /* maximum chunk size in bytes */ yyjson_val_chunk *chunks; /* a linked list of chunks, nullable */ } yyjson_val_pool; struct yyjson_mut_doc { yyjson_mut_val *root; /**< root value of the JSON document, nullable */ yyjson_alc alc; /**< a valid allocator, nonnull */ yyjson_str_pool str_pool; /**< string memory pool */ yyjson_val_pool val_pool; /**< value memory pool */ }; /* Ensures the capacity to at least equal to the specified byte length. */ yyjson_api bool unsafe_yyjson_str_pool_grow(yyjson_str_pool *pool, const yyjson_alc *alc, size_t len); /* Ensures the capacity to at least equal to the specified value count. */ yyjson_api bool unsafe_yyjson_val_pool_grow(yyjson_val_pool *pool, const yyjson_alc *alc, size_t count); /* Allocate memory for string. */ yyjson_api_inline char *unsafe_yyjson_mut_str_alc(yyjson_mut_doc *doc, size_t len) { char *mem; const yyjson_alc *alc = &doc->alc; yyjson_str_pool *pool = &doc->str_pool; if (yyjson_unlikely((size_t)(pool->end - pool->cur) <= len)) { if (yyjson_unlikely(!unsafe_yyjson_str_pool_grow(pool, alc, len + 1))) { return NULL; } } mem = pool->cur; pool->cur = mem + len + 1; return mem; } yyjson_api_inline char *unsafe_yyjson_mut_strncpy(yyjson_mut_doc *doc, const char *str, size_t len) { char *mem = unsafe_yyjson_mut_str_alc(doc, len); if (yyjson_unlikely(!mem)) return NULL; memcpy((void *)mem, (const void *)str, len); mem[len] = '\0'; return mem; } yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_val(yyjson_mut_doc *doc, size_t count) { yyjson_mut_val *val; yyjson_alc *alc = &doc->alc; yyjson_val_pool *pool = &doc->val_pool; if (yyjson_unlikely((size_t)(pool->end - pool->cur) < count)) { if (yyjson_unlikely(!unsafe_yyjson_val_pool_grow(pool, alc, count))) { return NULL; } } val = pool->cur; pool->cur += count; return val; } /*============================================================================== * Mutable JSON Document API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_get_root(yyjson_mut_doc *doc) { return doc ? doc->root : NULL; } yyjson_api_inline void yyjson_mut_doc_set_root(yyjson_mut_doc *doc, yyjson_mut_val *root) { if (doc) doc->root = root; } /*============================================================================== * Mutable JSON Value Type API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_mut_is_raw(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_raw(val) : false; } yyjson_api_inline bool yyjson_mut_is_null(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_null(val) : false; } yyjson_api_inline bool yyjson_mut_is_true(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_true(val) : false; } yyjson_api_inline bool yyjson_mut_is_false(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_false(val) : false; } yyjson_api_inline bool yyjson_mut_is_bool(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_bool(val) : false; } yyjson_api_inline bool yyjson_mut_is_uint(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_uint(val) : false; } yyjson_api_inline bool yyjson_mut_is_sint(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_sint(val) : false; } yyjson_api_inline bool yyjson_mut_is_int(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_int(val) : false; } yyjson_api_inline bool yyjson_mut_is_real(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_real(val) : false; } yyjson_api_inline bool yyjson_mut_is_num(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_num(val) : false; } yyjson_api_inline bool yyjson_mut_is_str(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_str(val) : false; } yyjson_api_inline bool yyjson_mut_is_arr(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_arr(val) : false; } yyjson_api_inline bool yyjson_mut_is_obj(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_obj(val) : false; } yyjson_api_inline bool yyjson_mut_is_ctn(yyjson_mut_val *val) { return val ? unsafe_yyjson_is_ctn(val) : false; } /*============================================================================== * Mutable JSON Value Content API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_type yyjson_mut_get_type(yyjson_mut_val *val) { return yyjson_get_type((yyjson_val *)val); } yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype(yyjson_mut_val *val) { return yyjson_get_subtype((yyjson_val *)val); } yyjson_api_inline uint8_t yyjson_mut_get_tag(yyjson_mut_val *val) { return yyjson_get_tag((yyjson_val *)val); } yyjson_api_inline const char *yyjson_mut_get_type_desc(yyjson_mut_val *val) { return yyjson_get_type_desc((yyjson_val *)val); } yyjson_api_inline const char *yyjson_mut_get_raw(yyjson_mut_val *val) { return yyjson_get_raw((yyjson_val *)val); } yyjson_api_inline bool yyjson_mut_get_bool(yyjson_mut_val *val) { return yyjson_get_bool((yyjson_val *)val); } yyjson_api_inline uint64_t yyjson_mut_get_uint(yyjson_mut_val *val) { return yyjson_get_uint((yyjson_val *)val); } yyjson_api_inline int64_t yyjson_mut_get_sint(yyjson_mut_val *val) { return yyjson_get_sint((yyjson_val *)val); } yyjson_api_inline int yyjson_mut_get_int(yyjson_mut_val *val) { return yyjson_get_int((yyjson_val *)val); } yyjson_api_inline double yyjson_mut_get_real(yyjson_mut_val *val) { return yyjson_get_real((yyjson_val *)val); } yyjson_api_inline double yyjson_mut_get_num(yyjson_mut_val *val) { return yyjson_get_num((yyjson_val *)val); } yyjson_api_inline const char *yyjson_mut_get_str(yyjson_mut_val *val) { return yyjson_get_str((yyjson_val *)val); } yyjson_api_inline size_t yyjson_mut_get_len(yyjson_mut_val *val) { return yyjson_get_len((yyjson_val *)val); } yyjson_api_inline bool yyjson_mut_equals_str(yyjson_mut_val *val, const char *str) { return yyjson_equals_str((yyjson_val *)val, str); } yyjson_api_inline bool yyjson_mut_equals_strn(yyjson_mut_val *val, const char *str, size_t len) { return yyjson_equals_strn((yyjson_val *)val, str, len); } yyjson_api bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs); yyjson_api_inline bool yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) { if (yyjson_unlikely(!lhs || !rhs)) return false; return unsafe_yyjson_mut_equals(lhs, rhs); } yyjson_api_inline bool yyjson_mut_set_raw(yyjson_mut_val *val, const char *raw, size_t len) { if (yyjson_unlikely(!val || !raw)) return false; unsafe_yyjson_set_raw(val, raw, len); return true; } yyjson_api_inline bool yyjson_mut_set_null(yyjson_mut_val *val) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_null(val); return true; } yyjson_api_inline bool yyjson_mut_set_bool(yyjson_mut_val *val, bool num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_bool(val, num); return true; } yyjson_api_inline bool yyjson_mut_set_uint(yyjson_mut_val *val, uint64_t num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_uint(val, num); return true; } yyjson_api_inline bool yyjson_mut_set_sint(yyjson_mut_val *val, int64_t num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_sint(val, num); return true; } yyjson_api_inline bool yyjson_mut_set_int(yyjson_mut_val *val, int num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_sint(val, (int64_t)num); return true; } yyjson_api_inline bool yyjson_mut_set_real(yyjson_mut_val *val, double num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_real(val, num); return true; } yyjson_api_inline bool yyjson_mut_set_str(yyjson_mut_val *val, const char *str) { if (yyjson_unlikely(!val || !str)) return false; unsafe_yyjson_set_str(val, str); return true; } yyjson_api_inline bool yyjson_mut_set_strn(yyjson_mut_val *val, const char *str, size_t len) { if (yyjson_unlikely(!val || !str)) return false; unsafe_yyjson_set_strn(val, str, len); return true; } yyjson_api_inline bool yyjson_mut_set_arr(yyjson_mut_val *val) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_arr(val, 0); return true; } yyjson_api_inline bool yyjson_mut_set_obj(yyjson_mut_val *val) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_obj(val, 0); return true; } /*============================================================================== * Mutable JSON Value Creation API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_mut_val *yyjson_mut_raw(yyjson_mut_doc *doc, const char *str) { if (yyjson_likely(str)) return yyjson_mut_rawn(doc, str, strlen(str)); return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawn(yyjson_mut_doc *doc, const char *str, size_t len) { if (yyjson_likely(doc && str)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; val->uni.str = str; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawcpy(yyjson_mut_doc *doc, const char *str) { if (yyjson_likely(str)) return yyjson_mut_rawncpy(doc, str, strlen(str)); return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawncpy(yyjson_mut_doc *doc, const char *str, size_t len) { if (yyjson_likely(doc && str)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); if (yyjson_likely(val && new_str)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; val->uni.str = new_str; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_null(yyjson_mut_doc *doc) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_true(yyjson_mut_doc *doc) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_false(yyjson_mut_doc *doc) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_bool(yyjson_mut_doc *doc, bool _val) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)_val << 3); return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_uint(yyjson_mut_doc *doc, uint64_t num) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = num; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_sint(yyjson_mut_doc *doc, int64_t num) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = num; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_int(yyjson_mut_doc *doc, int64_t num) { return yyjson_mut_sint(doc, num); } yyjson_api_inline yyjson_mut_val *yyjson_mut_real(yyjson_mut_doc *doc, double num) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.f64 = num; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_str(yyjson_mut_doc *doc, const char *str) { if (yyjson_likely(doc && str)) { size_t len = strlen(str); bool noesc = unsafe_yyjson_is_str_noesc(str, len); yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | (uint64_t)(YYJSON_TYPE_STR | sub); val->uni.str = str; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_strn(yyjson_mut_doc *doc, const char *str, size_t len) { if (yyjson_likely(doc && str)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = str; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_strcpy(yyjson_mut_doc *doc, const char *str) { if (yyjson_likely(doc && str)) { size_t len = strlen(str); bool noesc = unsafe_yyjson_is_str_noesc(str, len); yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); if (yyjson_likely(val && new_str)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | (uint64_t)(YYJSON_TYPE_STR | sub); val->uni.str = new_str; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_strncpy(yyjson_mut_doc *doc, const char *str, size_t len) { if (yyjson_likely(doc && str)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); if (yyjson_likely(val && new_str)) { val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = new_str; return val; } } return NULL; } /*============================================================================== * Mutable JSON Array API (Implementation) *============================================================================*/ yyjson_api_inline size_t yyjson_mut_arr_size(yyjson_mut_val *arr) { return yyjson_mut_is_arr(arr) ? unsafe_yyjson_get_len(arr) : 0; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get(yyjson_mut_val *arr, size_t idx) { if (yyjson_likely(idx < yyjson_mut_arr_size(arr))) { yyjson_mut_val *val = (yyjson_mut_val *)arr->uni.ptr; while (idx-- > 0) val = val->next; return val->next; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get_first( yyjson_mut_val *arr) { if (yyjson_likely(yyjson_mut_arr_size(arr) > 0)) { return ((yyjson_mut_val *)arr->uni.ptr)->next; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get_last( yyjson_mut_val *arr) { if (yyjson_likely(yyjson_mut_arr_size(arr) > 0)) { return ((yyjson_mut_val *)arr->uni.ptr); } return NULL; } /*============================================================================== * Mutable JSON Array Iterator API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_mut_arr_iter_init(yyjson_mut_val *arr, yyjson_mut_arr_iter *iter) { if (yyjson_likely(yyjson_mut_is_arr(arr) && iter)) { iter->idx = 0; iter->max = unsafe_yyjson_get_len(arr); iter->cur = iter->max ? (yyjson_mut_val *)arr->uni.ptr : NULL; iter->pre = NULL; iter->arr = arr; return true; } if (iter) memset(iter, 0, sizeof(yyjson_mut_arr_iter)); return false; } yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with( yyjson_mut_val *arr) { yyjson_mut_arr_iter iter; yyjson_mut_arr_iter_init(arr, &iter); return iter; } yyjson_api_inline bool yyjson_mut_arr_iter_has_next(yyjson_mut_arr_iter *iter) { return iter ? iter->idx < iter->max : false; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_next( yyjson_mut_arr_iter *iter) { if (iter && iter->idx < iter->max) { yyjson_mut_val *val = iter->cur; iter->pre = val; iter->cur = val->next; iter->idx++; return iter->cur; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_remove( yyjson_mut_arr_iter *iter) { if (yyjson_likely(iter && 0 < iter->idx && iter->idx <= iter->max)) { yyjson_mut_val *prev = iter->pre; yyjson_mut_val *cur = iter->cur; yyjson_mut_val *next = cur->next; if (yyjson_unlikely(iter->idx == iter->max)) iter->arr->uni.ptr = prev; iter->idx--; iter->max--; unsafe_yyjson_set_len(iter->arr, iter->max); prev->next = next; iter->cur = next; return cur; } return NULL; } /*============================================================================== * Mutable JSON Array Creation API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr(yyjson_mut_doc *doc) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_ARR | YYJSON_SUBTYPE_NONE; return val; } } return NULL; } #define yyjson_mut_arr_with_func(func) \ if (yyjson_likely(doc && ((0 < count && count < \ (~(size_t)0) / sizeof(yyjson_mut_val) && vals) || count == 0))) { \ yyjson_mut_val *arr = unsafe_yyjson_mut_val(doc, 1 + count); \ if (yyjson_likely(arr)) { \ arr->tag = ((uint64_t)count << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; \ if (count > 0) { \ size_t i; \ for (i = 0; i < count; i++) { \ yyjson_mut_val *val = arr + i + 1; \ func \ val->next = val + 1; \ } \ arr[count].next = arr + 1; \ arr->uni.ptr = arr + count; \ } \ return arr; \ } \ } \ return NULL yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_bool( yyjson_mut_doc *doc, const bool *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)vals[i] << 3); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint( yyjson_mut_doc *doc, const int64_t *vals, size_t count) { return yyjson_mut_arr_with_sint64(doc, vals, count); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint( yyjson_mut_doc *doc, const uint64_t *vals, size_t count) { return yyjson_mut_arr_with_uint64(doc, vals, count); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_real( yyjson_mut_doc *doc, const double *vals, size_t count) { return yyjson_mut_arr_with_double(doc, vals, count); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint8( yyjson_mut_doc *doc, const int8_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = (int64_t)vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint16( yyjson_mut_doc *doc, const int16_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint32( yyjson_mut_doc *doc, const int32_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint64( yyjson_mut_doc *doc, const int64_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint8( yyjson_mut_doc *doc, const uint8_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint16( yyjson_mut_doc *doc, const uint16_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint32( yyjson_mut_doc *doc, const uint32_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint64( yyjson_mut_doc *doc, const uint64_t *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_float( yyjson_mut_doc *doc, const float *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.f64 = (double)vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_double( yyjson_mut_doc *doc, const double *vals, size_t count) { yyjson_mut_arr_with_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.f64 = vals[i]; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_str( yyjson_mut_doc *doc, const char **vals, size_t count) { yyjson_mut_arr_with_func({ uint64_t len = (uint64_t)strlen(vals[i]); val->tag = (len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = vals[i]; if (yyjson_unlikely(!val->uni.str)) return NULL; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strn( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count) { if (yyjson_unlikely(count > 0 && !lens)) return NULL; yyjson_mut_arr_with_func({ val->tag = ((uint64_t)lens[i] << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = vals[i]; if (yyjson_unlikely(!val->uni.str)) return NULL; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strcpy( yyjson_mut_doc *doc, const char **vals, size_t count) { size_t len; const char *str; yyjson_mut_arr_with_func({ str = vals[i]; if (!str) return NULL; len = strlen(str); val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = unsafe_yyjson_mut_strncpy(doc, str, len); if (yyjson_unlikely(!val->uni.str)) return NULL; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strncpy( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count) { size_t len; const char *str; if (yyjson_unlikely(count > 0 && !lens)) return NULL; yyjson_mut_arr_with_func({ str = vals[i]; len = lens[i]; val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = unsafe_yyjson_mut_strncpy(doc, str, len); if (yyjson_unlikely(!val->uni.str)) return NULL; }); } #undef yyjson_mut_arr_with_func /*============================================================================== * Mutable JSON Array Modification API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_mut_arr_insert(yyjson_mut_val *arr, yyjson_mut_val *val, size_t idx) { if (yyjson_likely(yyjson_mut_is_arr(arr) && val)) { size_t len = unsafe_yyjson_get_len(arr); if (yyjson_likely(idx <= len)) { unsafe_yyjson_set_len(arr, len + 1); if (len == 0) { val->next = val; arr->uni.ptr = val; } else { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; if (idx == len) { prev->next = val; val->next = next; arr->uni.ptr = val; } else { while (idx-- > 0) { prev = next; next = next->next; } prev->next = val; val->next = next; } } return true; } } return false; } yyjson_api_inline bool yyjson_mut_arr_append(yyjson_mut_val *arr, yyjson_mut_val *val) { if (yyjson_likely(yyjson_mut_is_arr(arr) && val)) { size_t len = unsafe_yyjson_get_len(arr); unsafe_yyjson_set_len(arr, len + 1); if (len == 0) { val->next = val; } else { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; prev->next = val; val->next = next; } arr->uni.ptr = val; return true; } return false; } yyjson_api_inline bool yyjson_mut_arr_prepend(yyjson_mut_val *arr, yyjson_mut_val *val) { if (yyjson_likely(yyjson_mut_is_arr(arr) && val)) { size_t len = unsafe_yyjson_get_len(arr); unsafe_yyjson_set_len(arr, len + 1); if (len == 0) { val->next = val; arr->uni.ptr = val; } else { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; prev->next = val; val->next = next; } return true; } return false; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_replace(yyjson_mut_val *arr, size_t idx, yyjson_mut_val *val) { if (yyjson_likely(yyjson_mut_is_arr(arr) && val)) { size_t len = unsafe_yyjson_get_len(arr); if (yyjson_likely(idx < len)) { if (yyjson_likely(len > 1)) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; while (idx-- > 0) { prev = next; next = next->next; } prev->next = val; val->next = next->next; if ((void *)next == arr->uni.ptr) arr->uni.ptr = val; return next; } else { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); val->next = val; arr->uni.ptr = val; return prev; } } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove(yyjson_mut_val *arr, size_t idx) { if (yyjson_likely(yyjson_mut_is_arr(arr))) { size_t len = unsafe_yyjson_get_len(arr); if (yyjson_likely(idx < len)) { unsafe_yyjson_set_len(arr, len - 1); if (yyjson_likely(len > 1)) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; while (idx-- > 0) { prev = next; next = next->next; } prev->next = next->next; if ((void *)next == arr->uni.ptr) arr->uni.ptr = prev; return next; } else { return ((yyjson_mut_val *)arr->uni.ptr); } } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove_first( yyjson_mut_val *arr) { if (yyjson_likely(yyjson_mut_is_arr(arr))) { size_t len = unsafe_yyjson_get_len(arr); if (len > 1) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; prev->next = next->next; unsafe_yyjson_set_len(arr, len - 1); return next; } else if (len == 1) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); unsafe_yyjson_set_len(arr, 0); return prev; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_remove_last( yyjson_mut_val *arr) { if (yyjson_likely(yyjson_mut_is_arr(arr))) { size_t len = unsafe_yyjson_get_len(arr); if (yyjson_likely(len > 1)) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); yyjson_mut_val *next = prev->next; unsafe_yyjson_set_len(arr, len - 1); while (--len > 0) prev = prev->next; prev->next = next; next = (yyjson_mut_val *)arr->uni.ptr; arr->uni.ptr = prev; return next; } else if (len == 1) { yyjson_mut_val *prev = ((yyjson_mut_val *)arr->uni.ptr); unsafe_yyjson_set_len(arr, 0); return prev; } } return NULL; } yyjson_api_inline bool yyjson_mut_arr_remove_range(yyjson_mut_val *arr, size_t _idx, size_t _len) { if (yyjson_likely(yyjson_mut_is_arr(arr))) { yyjson_mut_val *prev, *next; bool tail_removed; size_t len = unsafe_yyjson_get_len(arr); if (yyjson_unlikely(_idx + _len > len)) return false; if (yyjson_unlikely(_len == 0)) return true; unsafe_yyjson_set_len(arr, len - _len); if (yyjson_unlikely(len == _len)) return true; tail_removed = (_idx + _len == len); prev = ((yyjson_mut_val *)arr->uni.ptr); while (_idx-- > 0) prev = prev->next; next = prev->next; while (_len-- > 0) next = next->next; prev->next = next; if (yyjson_unlikely(tail_removed)) arr->uni.ptr = prev; return true; } return false; } yyjson_api_inline bool yyjson_mut_arr_clear(yyjson_mut_val *arr) { if (yyjson_likely(yyjson_mut_is_arr(arr))) { unsafe_yyjson_set_len(arr, 0); return true; } return false; } yyjson_api_inline bool yyjson_mut_arr_rotate(yyjson_mut_val *arr, size_t idx) { if (yyjson_likely(yyjson_mut_is_arr(arr) && unsafe_yyjson_get_len(arr) > idx)) { yyjson_mut_val *val = (yyjson_mut_val *)arr->uni.ptr; while (idx-- > 0) val = val->next; arr->uni.ptr = (void *)val; return true; } return false; } /*============================================================================== * Mutable JSON Array Modification Convenience API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_mut_arr_add_val(yyjson_mut_val *arr, yyjson_mut_val *val) { return yyjson_mut_arr_append(arr, val); } yyjson_api_inline bool yyjson_mut_arr_add_null(yyjson_mut_doc *doc, yyjson_mut_val *arr) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_null(doc); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_true(yyjson_mut_doc *doc, yyjson_mut_val *arr) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_true(doc); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_false(yyjson_mut_doc *doc, yyjson_mut_val *arr) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_false(doc); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *arr, bool _val) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_bool(doc, _val); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *arr, uint64_t num) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_uint(doc, num); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_sint(doc, num); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_int(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_sint(doc, num); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_real(yyjson_mut_doc *doc, yyjson_mut_val *arr, double num) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_real(doc, num); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_str(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_str(doc, str); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_strn(doc, str, len); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_strcpy(doc, str); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline bool yyjson_mut_arr_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_strncpy(doc, str, len); return yyjson_mut_arr_append(arr, val); } return false; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *arr) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_arr(doc); return yyjson_mut_arr_append(arr, val) ? val : NULL; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *arr) { if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { yyjson_mut_val *val = yyjson_mut_obj(doc); return yyjson_mut_arr_append(arr, val) ? val : NULL; } return NULL; } /*============================================================================== * Mutable JSON Object API (Implementation) *============================================================================*/ yyjson_api_inline size_t yyjson_mut_obj_size(yyjson_mut_val *obj) { return yyjson_mut_is_obj(obj) ? unsafe_yyjson_get_len(obj) : 0; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_get(yyjson_mut_val *obj, const char *key) { return yyjson_mut_obj_getn(obj, key, key ? strlen(key) : 0); } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_getn(yyjson_mut_val *obj, const char *_key, size_t key_len) { size_t len = yyjson_mut_obj_size(obj); if (yyjson_likely(len && _key)) { yyjson_mut_val *key = ((yyjson_mut_val *)obj->uni.ptr)->next->next; while (len-- > 0) { if (unsafe_yyjson_equals_strn(key, _key, key_len)) return key->next; key = key->next->next; } } return NULL; } /*============================================================================== * Mutable JSON Object Iterator API (Implementation) *============================================================================*/ yyjson_api_inline bool yyjson_mut_obj_iter_init(yyjson_mut_val *obj, yyjson_mut_obj_iter *iter) { if (yyjson_likely(yyjson_mut_is_obj(obj) && iter)) { iter->idx = 0; iter->max = unsafe_yyjson_get_len(obj); iter->cur = iter->max ? (yyjson_mut_val *)obj->uni.ptr : NULL; iter->pre = NULL; iter->obj = obj; return true; } if (iter) memset(iter, 0, sizeof(yyjson_mut_obj_iter)); return false; } yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with( yyjson_mut_val *obj) { yyjson_mut_obj_iter iter; yyjson_mut_obj_iter_init(obj, &iter); return iter; } yyjson_api_inline bool yyjson_mut_obj_iter_has_next(yyjson_mut_obj_iter *iter) { return iter ? iter->idx < iter->max : false; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_next( yyjson_mut_obj_iter *iter) { if (iter && iter->idx < iter->max) { yyjson_mut_val *key = iter->cur; iter->pre = key; iter->cur = key->next->next; iter->idx++; return iter->cur; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get_val( yyjson_mut_val *key) { return key ? key->next : NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_remove( yyjson_mut_obj_iter *iter) { if (yyjson_likely(iter && 0 < iter->idx && iter->idx <= iter->max)) { yyjson_mut_val *prev = iter->pre; yyjson_mut_val *cur = iter->cur; yyjson_mut_val *next = cur->next->next; if (yyjson_unlikely(iter->idx == iter->max)) iter->obj->uni.ptr = prev; iter->idx--; iter->max--; unsafe_yyjson_set_len(iter->obj, iter->max); prev->next->next = next; iter->cur = prev; return cur->next; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get( yyjson_mut_obj_iter *iter, const char *key) { return yyjson_mut_obj_iter_getn(iter, key, key ? strlen(key) : 0); } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_getn( yyjson_mut_obj_iter *iter, const char *key, size_t key_len) { if (iter && key) { size_t idx = 0; size_t max = iter->max; yyjson_mut_val *pre, *cur = iter->cur; while (idx++ < max) { pre = cur; cur = cur->next->next; if (unsafe_yyjson_equals_strn(cur, key, key_len)) { iter->idx += idx; if (iter->idx > max) iter->idx -= max + 1; iter->pre = pre; iter->cur = cur; return cur->next; } } } return NULL; } /*============================================================================== * Mutable JSON Object Creation API (Implementation) *============================================================================*/ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj(yyjson_mut_doc *doc) { if (yyjson_likely(doc)) { yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); if (yyjson_likely(val)) { val->tag = YYJSON_TYPE_OBJ | YYJSON_SUBTYPE_NONE; return val; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_with_str(yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count) { if (yyjson_likely(doc && ((count > 0 && keys && vals) || (count == 0)))) { yyjson_mut_val *obj = unsafe_yyjson_mut_val(doc, 1 + count * 2); if (yyjson_likely(obj)) { obj->tag = ((uint64_t)count << YYJSON_TAG_BIT) | YYJSON_TYPE_OBJ; if (count > 0) { size_t i; for (i = 0; i < count; i++) { yyjson_mut_val *key = obj + (i * 2 + 1); yyjson_mut_val *val = obj + (i * 2 + 2); uint64_t key_len = (uint64_t)strlen(keys[i]); uint64_t val_len = (uint64_t)strlen(vals[i]); key->tag = (key_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->tag = (val_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; key->uni.str = keys[i]; val->uni.str = vals[i]; key->next = val; val->next = val + 1; } obj[count * 2].next = obj + 1; obj->uni.ptr = obj + (count * 2 - 1); } return obj; } } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_with_kv(yyjson_mut_doc *doc, const char **pairs, size_t count) { if (yyjson_likely(doc && ((count > 0 && pairs) || (count == 0)))) { yyjson_mut_val *obj = unsafe_yyjson_mut_val(doc, 1 + count * 2); if (yyjson_likely(obj)) { obj->tag = ((uint64_t)count << YYJSON_TAG_BIT) | YYJSON_TYPE_OBJ; if (count > 0) { size_t i; for (i = 0; i < count; i++) { yyjson_mut_val *key = obj + (i * 2 + 1); yyjson_mut_val *val = obj + (i * 2 + 2); const char *key_str = pairs[i * 2 + 0]; const char *val_str = pairs[i * 2 + 1]; uint64_t key_len = (uint64_t)strlen(key_str); uint64_t val_len = (uint64_t)strlen(val_str); key->tag = (key_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->tag = (val_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; key->uni.str = key_str; val->uni.str = val_str; key->next = val; val->next = val + 1; } obj[count * 2].next = obj + 1; obj->uni.ptr = obj + (count * 2 - 1); } return obj; } } return NULL; } /*============================================================================== * Mutable JSON Object Modification API (Implementation) *============================================================================*/ yyjson_api_inline void unsafe_yyjson_mut_obj_add(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val, size_t len) { if (yyjson_likely(len)) { yyjson_mut_val *prev_val = ((yyjson_mut_val *)obj->uni.ptr)->next; yyjson_mut_val *next_key = prev_val->next; prev_val->next = key; val->next = next_key; } else { val->next = key; } key->next = val; obj->uni.ptr = (void *)key; unsafe_yyjson_set_len(obj, len + 1); } yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_obj_remove( yyjson_mut_val *obj, const char *key, size_t key_len) { size_t obj_len = unsafe_yyjson_get_len(obj); if (obj_len) { yyjson_mut_val *pre_key = (yyjson_mut_val *)obj->uni.ptr; yyjson_mut_val *cur_key = pre_key->next->next; yyjson_mut_val *removed_item = NULL; size_t i; for (i = 0; i < obj_len; i++) { if (unsafe_yyjson_equals_strn(cur_key, key, key_len)) { if (!removed_item) removed_item = cur_key->next; cur_key = cur_key->next->next; pre_key->next->next = cur_key; if (i + 1 == obj_len) obj->uni.ptr = pre_key; i--; obj_len--; } else { pre_key = cur_key; cur_key = cur_key->next->next; } } unsafe_yyjson_set_len(obj, obj_len); return removed_item; } else { return NULL; } } yyjson_api_inline bool unsafe_yyjson_mut_obj_replace(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val) { size_t key_len = unsafe_yyjson_get_len(key); size_t obj_len = unsafe_yyjson_get_len(obj); if (obj_len) { yyjson_mut_val *pre_key = (yyjson_mut_val *)obj->uni.ptr; yyjson_mut_val *cur_key = pre_key->next->next; size_t i; for (i = 0; i < obj_len; i++) { if (unsafe_yyjson_equals_strn(cur_key, key->uni.str, key_len)) { cur_key->next->tag = val->tag; cur_key->next->uni.u64 = val->uni.u64; return true; } else { cur_key = cur_key->next->next; } } } return false; } yyjson_api_inline void unsafe_yyjson_mut_obj_rotate(yyjson_mut_val *obj, size_t idx) { yyjson_mut_val *key = (yyjson_mut_val *)obj->uni.ptr; while (idx-- > 0) key = key->next->next; obj->uni.ptr = (void *)key; } yyjson_api_inline bool yyjson_mut_obj_add(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val) { if (yyjson_likely(yyjson_mut_is_obj(obj) && yyjson_mut_is_str(key) && val)) { unsafe_yyjson_mut_obj_add(obj, key, val, unsafe_yyjson_get_len(obj)); return true; } return false; } yyjson_api_inline bool yyjson_mut_obj_put(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val) { bool replaced = false; size_t key_len; yyjson_mut_obj_iter iter; yyjson_mut_val *cur_key; if (yyjson_unlikely(!yyjson_mut_is_obj(obj) || !yyjson_mut_is_str(key))) return false; key_len = unsafe_yyjson_get_len(key); yyjson_mut_obj_iter_init(obj, &iter); while ((cur_key = yyjson_mut_obj_iter_next(&iter)) != 0) { if (unsafe_yyjson_equals_strn(cur_key, key->uni.str, key_len)) { if (!replaced && val) { replaced = true; val->next = cur_key->next->next; cur_key->next = val; } else { yyjson_mut_obj_iter_remove(&iter); } } } if (!replaced && val) unsafe_yyjson_mut_obj_add(obj, key, val, iter.max); return true; } yyjson_api_inline bool yyjson_mut_obj_insert(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val, size_t idx) { if (yyjson_likely(yyjson_mut_is_obj(obj) && yyjson_mut_is_str(key) && val)) { size_t len = unsafe_yyjson_get_len(obj); if (yyjson_likely(len >= idx)) { if (len > idx) { void *ptr = obj->uni.ptr; unsafe_yyjson_mut_obj_rotate(obj, idx); unsafe_yyjson_mut_obj_add(obj, key, val, len); obj->uni.ptr = ptr; } else { unsafe_yyjson_mut_obj_add(obj, key, val, len); } return true; } } return false; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove(yyjson_mut_val *obj, yyjson_mut_val *key) { if (yyjson_likely(yyjson_mut_is_obj(obj) && yyjson_mut_is_str(key))) { return unsafe_yyjson_mut_obj_remove(obj, key->uni.str, unsafe_yyjson_get_len(key)); } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_key( yyjson_mut_val *obj, const char *key) { if (yyjson_likely(yyjson_mut_is_obj(obj) && key)) { size_t key_len = strlen(key); return unsafe_yyjson_mut_obj_remove(obj, key, key_len); } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_keyn( yyjson_mut_val *obj, const char *key, size_t key_len) { if (yyjson_likely(yyjson_mut_is_obj(obj) && key)) { return unsafe_yyjson_mut_obj_remove(obj, key, key_len); } return NULL; } yyjson_api_inline bool yyjson_mut_obj_clear(yyjson_mut_val *obj) { if (yyjson_likely(yyjson_mut_is_obj(obj))) { unsafe_yyjson_set_len(obj, 0); return true; } return false; } yyjson_api_inline bool yyjson_mut_obj_replace(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val) { if (yyjson_likely(yyjson_mut_is_obj(obj) && yyjson_mut_is_str(key) && val)) { return unsafe_yyjson_mut_obj_replace(obj, key, val); } return false; } yyjson_api_inline bool yyjson_mut_obj_rotate(yyjson_mut_val *obj, size_t idx) { if (yyjson_likely(yyjson_mut_is_obj(obj) && unsafe_yyjson_get_len(obj) > idx)) { unsafe_yyjson_mut_obj_rotate(obj, idx); return true; } return false; } /*============================================================================== * Mutable JSON Object Modification Convenience API (Implementation) *============================================================================*/ #define yyjson_mut_obj_add_func(func) \ if (yyjson_likely(doc && yyjson_mut_is_obj(obj) && _key)) { \ yyjson_mut_val *key = unsafe_yyjson_mut_val(doc, 2); \ if (yyjson_likely(key)) { \ size_t len = unsafe_yyjson_get_len(obj); \ yyjson_mut_val *val = key + 1; \ size_t key_len = strlen(_key); \ bool noesc = unsafe_yyjson_is_str_noesc(_key, key_len); \ key->tag = YYJSON_TYPE_STR; \ key->tag |= noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; \ key->tag |= (uint64_t)strlen(_key) << YYJSON_TAG_BIT; \ key->uni.str = _key; \ func \ unsafe_yyjson_mut_obj_add(obj, key, val, len); \ return true; \ } \ } \ return false yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE; }); } yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; }); } yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; }); } yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, bool _val) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)(_val) << 3); }); } yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, uint64_t _val) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; val->uni.u64 = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, int64_t _val) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, int64_t _val) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; val->uni.i64 = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, double _val) { yyjson_mut_obj_add_func({ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; val->uni.f64 = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, const char *_val) { if (yyjson_unlikely(!_val)) return false; yyjson_mut_obj_add_func({ size_t val_len = strlen(_val); bool val_noesc = unsafe_yyjson_is_str_noesc(_val, val_len); val->tag = ((uint64_t)strlen(_val) << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->tag |= val_noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; val->uni.str = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, const char *_val, size_t _len) { if (yyjson_unlikely(!_val)) return false; yyjson_mut_obj_add_func({ val->tag = ((uint64_t)_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = _val; }); } yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, const char *_val) { if (yyjson_unlikely(!_val)) return false; yyjson_mut_obj_add_func({ size_t _len = strlen(_val); val->uni.str = unsafe_yyjson_mut_strncpy(doc, _val, _len); if (yyjson_unlikely(!val->uni.str)) return false; val->tag = ((uint64_t)_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; }); } yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, const char *_val, size_t _len) { if (yyjson_unlikely(!_val)) return false; yyjson_mut_obj_add_func({ val->uni.str = unsafe_yyjson_mut_strncpy(doc, _val, _len); if (yyjson_unlikely(!val->uni.str)) return false; val->tag = ((uint64_t)_len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { yyjson_mut_val *key = yyjson_mut_str(doc, _key); yyjson_mut_val *val = yyjson_mut_arr(doc); return yyjson_mut_obj_add(obj, key, val) ? val : NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { yyjson_mut_val *key = yyjson_mut_str(doc, _key); yyjson_mut_val *val = yyjson_mut_obj(doc); return yyjson_mut_obj_add(obj, key, val) ? val : NULL; } yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, yyjson_mut_val *_val) { if (yyjson_unlikely(!_val)) return false; yyjson_mut_obj_add_func({ val = _val; }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_str(yyjson_mut_val *obj, const char *key) { return yyjson_mut_obj_remove_strn(obj, key, key ? strlen(key) : 0); } yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_strn( yyjson_mut_val *obj, const char *_key, size_t _len) { if (yyjson_likely(yyjson_mut_is_obj(obj) && _key)) { yyjson_mut_val *key; yyjson_mut_obj_iter iter; yyjson_mut_val *val_removed = NULL; yyjson_mut_obj_iter_init(obj, &iter); while ((key = yyjson_mut_obj_iter_next(&iter)) != NULL) { if (unsafe_yyjson_equals_strn(key, _key, _len)) { if (!val_removed) val_removed = key->next; yyjson_mut_obj_iter_remove(&iter); } } return val_removed; } return NULL; } yyjson_api_inline bool yyjson_mut_obj_rename_key(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *new_key) { if (!key || !new_key) return false; return yyjson_mut_obj_rename_keyn(doc, obj, key, strlen(key), new_key, strlen(new_key)); } yyjson_api_inline bool yyjson_mut_obj_rename_keyn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, size_t len, const char *new_key, size_t new_len) { char *cpy_key = NULL; yyjson_mut_val *old_key; yyjson_mut_obj_iter iter; if (!doc || !obj || !key || !new_key) return false; yyjson_mut_obj_iter_init(obj, &iter); while ((old_key = yyjson_mut_obj_iter_next(&iter))) { if (unsafe_yyjson_equals_strn((void *)old_key, key, len)) { if (!cpy_key) { cpy_key = unsafe_yyjson_mut_strncpy(doc, new_key, new_len); if (!cpy_key) return false; } yyjson_mut_set_strn(old_key, cpy_key, new_len); } } return cpy_key != NULL; } /*============================================================================== * JSON Pointer API (Implementation) *============================================================================*/ #define yyjson_ptr_set_err(_code, _msg) do { \ if (err) { \ err->code = YYJSON_PTR_ERR_##_code; \ err->msg = _msg; \ err->pos = 0; \ } \ } while(false) /* require: val != NULL, *ptr == '/', len > 0 */ yyjson_api yyjson_val *unsafe_yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err); /* require: val != NULL, *ptr == '/', len > 0 */ yyjson_api yyjson_mut_val *unsafe_yyjson_mut_ptr_getx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /* require: val/new_val/doc != NULL, *ptr == '/', len > 0 */ yyjson_api bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, bool insert_new, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /* require: val/err != NULL, *ptr == '/', len > 0 */ yyjson_api yyjson_mut_val *unsafe_yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); /* require: val/err != NULL, *ptr == '/', len > 0 */ yyjson_api yyjson_mut_val *unsafe_yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err); yyjson_api_inline yyjson_val *yyjson_doc_ptr_get(yyjson_doc *doc, const char *ptr) { if (yyjson_unlikely(!ptr)) return NULL; return yyjson_doc_ptr_getn(doc, ptr, strlen(ptr)); } yyjson_api_inline yyjson_val *yyjson_doc_ptr_getn(yyjson_doc *doc, const char *ptr, size_t len) { return yyjson_doc_ptr_getx(doc, ptr, len, NULL); } yyjson_api_inline yyjson_val *yyjson_doc_ptr_getx(yyjson_doc *doc, const char *ptr, size_t len, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(!doc->root)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { return doc->root; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_ptr_getx(doc->root, ptr, len, err); } yyjson_api_inline yyjson_val *yyjson_ptr_get(yyjson_val *val, const char *ptr) { if (yyjson_unlikely(!ptr)) return NULL; return yyjson_ptr_getn(val, ptr, strlen(ptr)); } yyjson_api_inline yyjson_val *yyjson_ptr_getn(yyjson_val *val, const char *ptr, size_t len) { return yyjson_ptr_getx(val, ptr, len, NULL); } yyjson_api_inline yyjson_val *yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (yyjson_unlikely(!val || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { return val; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_ptr_getx(val, ptr, len, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_get(yyjson_mut_doc *doc, const char *ptr) { if (!ptr) return NULL; return yyjson_mut_doc_ptr_getn(doc, ptr, strlen(ptr)); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_getn(yyjson_mut_doc *doc, const char *ptr, size_t len) { return yyjson_mut_doc_ptr_getx(doc, ptr, len, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_getx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(!doc->root)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { return doc->root; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_getx(doc->root, ptr, len, ctx, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_get(yyjson_mut_val *val, const char *ptr) { if (!ptr) return NULL; return yyjson_mut_ptr_getn(val, ptr, strlen(ptr)); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_getn(yyjson_mut_val *val, const char *ptr, size_t len) { return yyjson_mut_ptr_getx(val, ptr, len, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_getx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!val || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { return val; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_getx(val, ptr, len, ctx, err); } yyjson_api_inline bool yyjson_mut_doc_ptr_add(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val) { if (yyjson_unlikely(!ptr)) return false; return yyjson_mut_doc_ptr_addn(doc, ptr, strlen(ptr), new_val); } yyjson_api_inline bool yyjson_mut_doc_ptr_addn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val) { return yyjson_mut_doc_ptr_addx(doc, ptr, len, new_val, true, NULL, NULL); } yyjson_api_inline bool yyjson_mut_doc_ptr_addx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!doc || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; } if (yyjson_unlikely(len == 0)) { if (doc->root) { yyjson_ptr_set_err(SET_ROOT, "cannot set document's root"); return false; } else { doc->root = new_val; return true; } } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return false; } if (yyjson_unlikely(!doc->root && !create_parent)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return false; } if (yyjson_unlikely(!doc->root)) { yyjson_mut_val *root = yyjson_mut_obj(doc); if (yyjson_unlikely(!root)) { yyjson_ptr_set_err(MEMORY_ALLOCATION, "failed to create value"); return false; } if (unsafe_yyjson_mut_ptr_putx(root, ptr, len, new_val, doc, create_parent, true, ctx, err)) { doc->root = root; return true; } return false; } return unsafe_yyjson_mut_ptr_putx(doc->root, ptr, len, new_val, doc, create_parent, true, ctx, err); } yyjson_api_inline bool yyjson_mut_ptr_add(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc) { if (yyjson_unlikely(!ptr)) return false; return yyjson_mut_ptr_addn(val, ptr, strlen(ptr), new_val, doc); } yyjson_api_inline bool yyjson_mut_ptr_addn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc) { return yyjson_mut_ptr_addx(val, ptr, len, new_val, doc, true, NULL, NULL); } yyjson_api_inline bool yyjson_mut_ptr_addx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!val || !ptr || !new_val || !doc)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; } if (yyjson_unlikely(len == 0)) { yyjson_ptr_set_err(SET_ROOT, "cannot set root"); return false; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return false; } return unsafe_yyjson_mut_ptr_putx(val, ptr, len, new_val, doc, create_parent, true, ctx, err); } yyjson_api_inline bool yyjson_mut_doc_ptr_set(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val) { if (yyjson_unlikely(!ptr)) return false; return yyjson_mut_doc_ptr_setn(doc, ptr, strlen(ptr), new_val); } yyjson_api_inline bool yyjson_mut_doc_ptr_setn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val) { return yyjson_mut_doc_ptr_setx(doc, ptr, len, new_val, true, NULL, NULL); } yyjson_api_inline bool yyjson_mut_doc_ptr_setx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; } if (yyjson_unlikely(len == 0)) { if (ctx) ctx->old = doc->root; doc->root = new_val; return true; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return false; } if (!new_val) { if (!doc->root) { yyjson_ptr_set_err(RESOLVE, "JSON pointer cannot be resolved"); return false; } return !!unsafe_yyjson_mut_ptr_removex(doc->root, ptr, len, ctx, err); } if (yyjson_unlikely(!doc->root && !create_parent)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return false; } if (yyjson_unlikely(!doc->root)) { yyjson_mut_val *root = yyjson_mut_obj(doc); if (yyjson_unlikely(!root)) { yyjson_ptr_set_err(MEMORY_ALLOCATION, "failed to create value"); return false; } if (unsafe_yyjson_mut_ptr_putx(root, ptr, len, new_val, doc, create_parent, false, ctx, err)) { doc->root = root; return true; } return false; } return unsafe_yyjson_mut_ptr_putx(doc->root, ptr, len, new_val, doc, create_parent, false, ctx, err); } yyjson_api_inline bool yyjson_mut_ptr_set(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc) { if (yyjson_unlikely(!ptr)) return false; return yyjson_mut_ptr_setn(val, ptr, strlen(ptr), new_val, doc); } yyjson_api_inline bool yyjson_mut_ptr_setn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc) { return yyjson_mut_ptr_setx(val, ptr, len, new_val, doc, true, NULL, NULL); } yyjson_api_inline bool yyjson_mut_ptr_setx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!val || !ptr || !doc)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; } if (yyjson_unlikely(len == 0)) { yyjson_ptr_set_err(SET_ROOT, "cannot set root"); return false; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return false; } if (!new_val) { return !!unsafe_yyjson_mut_ptr_removex(val, ptr, len, ctx, err); } return unsafe_yyjson_mut_ptr_putx(val, ptr, len, new_val, doc, create_parent, false, ctx, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replace( yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val) { if (!ptr) return NULL; return yyjson_mut_doc_ptr_replacen(doc, ptr, strlen(ptr), new_val); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacen( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val) { return yyjson_mut_doc_ptr_replacex(doc, ptr, len, new_val, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!doc || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { yyjson_mut_val *root = doc->root; if (yyjson_unlikely(!root)) { yyjson_ptr_set_err(RESOLVE, "JSON pointer cannot be resolved"); return NULL; } if (ctx) ctx->old = root; doc->root = new_val; return root; } if (yyjson_unlikely(!doc->root)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return NULL; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_replacex(doc->root, ptr, len, new_val, ctx, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replace( yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val) { if (!ptr) return NULL; return yyjson_mut_ptr_replacen(val, ptr, strlen(ptr), new_val); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacen( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val) { return yyjson_mut_ptr_replacex(val, ptr, len, new_val, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!val || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { yyjson_ptr_set_err(SET_ROOT, "cannot set root"); return NULL; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_replacex(val, ptr, len, new_val, ctx, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_remove( yyjson_mut_doc *doc, const char *ptr) { if (!ptr) return NULL; return yyjson_mut_doc_ptr_removen(doc, ptr, strlen(ptr)); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removen( yyjson_mut_doc *doc, const char *ptr, size_t len) { return yyjson_mut_doc_ptr_removex(doc, ptr, len, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(!doc->root)) { yyjson_ptr_set_err(NULL_ROOT, "document's root is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { yyjson_mut_val *root = doc->root; if (ctx) ctx->old = root; doc->root = NULL; return root; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_removex(doc->root, ptr, len, ctx, err); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_remove(yyjson_mut_val *val, const char *ptr) { if (!ptr) return NULL; return yyjson_mut_ptr_removen(val, ptr, strlen(ptr)); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_removen(yyjson_mut_val *val, const char *ptr, size_t len) { return yyjson_mut_ptr_removex(val, ptr, len, NULL, NULL); } yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); if (yyjson_unlikely(!val || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; } if (yyjson_unlikely(len == 0)) { yyjson_ptr_set_err(SET_ROOT, "cannot set root"); return NULL; } if (yyjson_unlikely(*ptr != '/')) { yyjson_ptr_set_err(SYNTAX, "no prefix '/'"); return NULL; } return unsafe_yyjson_mut_ptr_removex(val, ptr, len, ctx, err); } yyjson_api_inline bool yyjson_ptr_ctx_append(yyjson_ptr_ctx *ctx, yyjson_mut_val *key, yyjson_mut_val *val) { yyjson_mut_val *ctn, *pre_key, *pre_val, *cur_key, *cur_val; if (!ctx || !ctx->ctn || !val) return false; ctn = ctx->ctn; if (yyjson_mut_is_obj(ctn)) { if (!key) return false; key->next = val; pre_key = ctx->pre; if (unsafe_yyjson_get_len(ctn) == 0) { val->next = key; ctn->uni.ptr = key; ctx->pre = key; } else if (!pre_key) { pre_key = (yyjson_mut_val *)ctn->uni.ptr; pre_val = pre_key->next; val->next = pre_val->next; pre_val->next = key; ctn->uni.ptr = key; ctx->pre = pre_key; } else { cur_key = pre_key->next->next; cur_val = cur_key->next; val->next = cur_val->next; cur_val->next = key; if (ctn->uni.ptr == cur_key) ctn->uni.ptr = key; ctx->pre = cur_key; } } else { pre_val = ctx->pre; if (unsafe_yyjson_get_len(ctn) == 0) { val->next = val; ctn->uni.ptr = val; ctx->pre = val; } else if (!pre_val) { pre_val = (yyjson_mut_val *)ctn->uni.ptr; val->next = pre_val->next; pre_val->next = val; ctn->uni.ptr = val; ctx->pre = pre_val; } else { cur_val = pre_val->next; val->next = cur_val->next; cur_val->next = val; if (ctn->uni.ptr == cur_val) ctn->uni.ptr = val; ctx->pre = cur_val; } } unsafe_yyjson_inc_len(ctn); return true; } yyjson_api_inline bool yyjson_ptr_ctx_replace(yyjson_ptr_ctx *ctx, yyjson_mut_val *val) { yyjson_mut_val *ctn, *pre_key, *cur_key, *pre_val, *cur_val; if (!ctx || !ctx->ctn || !ctx->pre || !val) return false; ctn = ctx->ctn; if (yyjson_mut_is_obj(ctn)) { pre_key = ctx->pre; pre_val = pre_key->next; cur_key = pre_val->next; cur_val = cur_key->next; /* replace current value */ cur_key->next = val; val->next = cur_val->next; ctx->old = cur_val; } else { pre_val = ctx->pre; cur_val = pre_val->next; /* replace current value */ if (pre_val != cur_val) { val->next = cur_val->next; pre_val->next = val; if (ctn->uni.ptr == cur_val) ctn->uni.ptr = val; } else { val->next = val; ctn->uni.ptr = val; ctx->pre = val; } ctx->old = cur_val; } return true; } yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx) { yyjson_mut_val *ctn, *pre_key, *pre_val, *cur_key, *cur_val; size_t len; if (!ctx || !ctx->ctn || !ctx->pre) return false; ctn = ctx->ctn; if (yyjson_mut_is_obj(ctn)) { pre_key = ctx->pre; pre_val = pre_key->next; cur_key = pre_val->next; cur_val = cur_key->next; /* remove current key-value */ pre_val->next = cur_val->next; if (ctn->uni.ptr == cur_key) ctn->uni.ptr = pre_key; ctx->pre = NULL; ctx->old = cur_val; } else { pre_val = ctx->pre; cur_val = pre_val->next; /* remove current key-value */ pre_val->next = cur_val->next; if (ctn->uni.ptr == cur_val) ctn->uni.ptr = pre_val; ctx->pre = NULL; ctx->old = cur_val; } len = unsafe_yyjson_get_len(ctn) - 1; if (len == 0) ctn->uni.ptr = NULL; unsafe_yyjson_set_len(ctn, len); return true; } #undef yyjson_ptr_set_err /*============================================================================== * JSON Value at Pointer API (Implementation) *============================================================================*/ /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is type bool. Returns true if value at `ptr` exists and is the correct type, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_bool( yyjson_val *root, const char *ptr, bool *value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && yyjson_is_bool(val)) { *value = unsafe_yyjson_get_bool(val); return true; } else { return false; } } /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is an integer that fits in `uint64_t`. Returns true if successful, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_uint( yyjson_val *root, const char *ptr, uint64_t *value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && val) { uint64_t ret = val->uni.u64; if (unsafe_yyjson_is_uint(val) || (unsafe_yyjson_is_sint(val) && !(ret >> 63))) { *value = ret; return true; } } return false; } /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is an integer that fits in `int64_t`. Returns true if successful, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_sint( yyjson_val *root, const char *ptr, int64_t *value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && val) { int64_t ret = val->uni.i64; if (unsafe_yyjson_is_sint(val) || (unsafe_yyjson_is_uint(val) && ret >= 0)) { *value = ret; return true; } } return false; } /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is type real. Returns true if value at `ptr` exists and is the correct type, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_real( yyjson_val *root, const char *ptr, double *value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && yyjson_is_real(val)) { *value = unsafe_yyjson_get_real(val); return true; } else { return false; } } /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is type sint, uint or real. Returns true if value at `ptr` exists and is the correct type, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_num( yyjson_val *root, const char *ptr, double *value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && yyjson_is_num(val)) { *value = unsafe_yyjson_get_num(val); return true; } else { return false; } } /** Set provided `value` if the JSON Pointer (RFC 6901) exists and is type string. Returns true if value at `ptr` exists and is the correct type, otherwise false. */ yyjson_api_inline bool yyjson_ptr_get_str( yyjson_val *root, const char *ptr, const char **value) { yyjson_val *val = yyjson_ptr_get(root, ptr); if (value && yyjson_is_str(val)) { *value = unsafe_yyjson_get_str(val); return true; } else { return false; } } /*============================================================================== * Deprecated *============================================================================*/ /** @deprecated renamed to `yyjson_doc_ptr_get` */ yyjson_deprecated("renamed to yyjson_doc_ptr_get") yyjson_api_inline yyjson_val *yyjson_doc_get_pointer(yyjson_doc *doc, const char *ptr) { return yyjson_doc_ptr_get(doc, ptr); } /** @deprecated renamed to `yyjson_doc_ptr_getn` */ yyjson_deprecated("renamed to yyjson_doc_ptr_getn") yyjson_api_inline yyjson_val *yyjson_doc_get_pointern(yyjson_doc *doc, const char *ptr, size_t len) { return yyjson_doc_ptr_getn(doc, ptr, len); } /** @deprecated renamed to `yyjson_mut_doc_ptr_get` */ yyjson_deprecated("renamed to yyjson_mut_doc_ptr_get") yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_get_pointer( yyjson_mut_doc *doc, const char *ptr) { return yyjson_mut_doc_ptr_get(doc, ptr); } /** @deprecated renamed to `yyjson_mut_doc_ptr_getn` */ yyjson_deprecated("renamed to yyjson_mut_doc_ptr_getn") yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_get_pointern( yyjson_mut_doc *doc, const char *ptr, size_t len) { return yyjson_mut_doc_ptr_getn(doc, ptr, len); } /** @deprecated renamed to `yyjson_ptr_get` */ yyjson_deprecated("renamed to yyjson_ptr_get") yyjson_api_inline yyjson_val *yyjson_get_pointer(yyjson_val *val, const char *ptr) { return yyjson_ptr_get(val, ptr); } /** @deprecated renamed to `yyjson_ptr_getn` */ yyjson_deprecated("renamed to yyjson_ptr_getn") yyjson_api_inline yyjson_val *yyjson_get_pointern(yyjson_val *val, const char *ptr, size_t len) { return yyjson_ptr_getn(val, ptr, len); } /** @deprecated renamed to `yyjson_mut_ptr_get` */ yyjson_deprecated("renamed to yyjson_mut_ptr_get") yyjson_api_inline yyjson_mut_val *yyjson_mut_get_pointer(yyjson_mut_val *val, const char *ptr) { return yyjson_mut_ptr_get(val, ptr); } /** @deprecated renamed to `yyjson_mut_ptr_getn` */ yyjson_deprecated("renamed to yyjson_mut_ptr_getn") yyjson_api_inline yyjson_mut_val *yyjson_mut_get_pointern(yyjson_mut_val *val, const char *ptr, size_t len) { return yyjson_mut_ptr_getn(val, ptr, len); } /** @deprecated renamed to `yyjson_mut_ptr_getn` */ yyjson_deprecated("renamed to unsafe_yyjson_ptr_getn") yyjson_api_inline yyjson_val *unsafe_yyjson_get_pointer(yyjson_val *val, const char *ptr, size_t len) { yyjson_ptr_err err; return unsafe_yyjson_ptr_getx(val, ptr, len, &err); } /** @deprecated renamed to `unsafe_yyjson_mut_ptr_getx` */ yyjson_deprecated("renamed to unsafe_yyjson_mut_ptr_getx") yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_get_pointer( yyjson_mut_val *val, const char *ptr, size_t len) { yyjson_ptr_err err; return unsafe_yyjson_mut_ptr_getx(val, ptr, len, NULL, &err); } /*============================================================================== * Compiler Hint End *============================================================================*/ #if defined(__clang__) # pragma clang diagnostic pop #elif defined(__GNUC__) # if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic pop # endif #elif defined(_MSC_VER) # pragma warning(pop) #endif /* warning suppress end */ #ifdef __cplusplus } #endif /* extern "C" end */ #endif /* YYJSON_H */ orjson-3.9.15/integration/000077500000000000000000000000001456615046100154565ustar00rootroot00000000000000orjson-3.9.15/integration/client000077500000000000000000000011531456615046100166620ustar00rootroot00000000000000#!/usr/bin/env python3 import asyncio import sys import time import httpx port = sys.argv[1] url = f"http://127.0.0.1:{port}" timeout = httpx.Timeout(5.0) client = httpx.AsyncClient(timeout=timeout) stop_time = time.time() + 5 TEST_MESSAGE = "http test running..." async def main(): sys.stdout.write(TEST_MESSAGE) sys.stdout.flush() count = 0 while time.time() < stop_time: res = await client.get(url) count += 1 sys.stdout.write(f"\r{TEST_MESSAGE} ok, {count} requests made\n") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) asyncio.run(main()) loop.close() orjson-3.9.15/integration/http000077500000000000000000000002321456615046100163600ustar00rootroot00000000000000#!/usr/bin/env bash set -e _dir="$(dirname "${BASH_SOURCE[0]}")" PYTHONPATH=${_dir} gunicorn --preload --bind localhost:8001 --workers 2 "$@" wsgi:app orjson-3.9.15/integration/init000077500000000000000000000012711456615046100163500ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import multiprocessing.pool import sys import orjson NUM_PROC = 16 TEST_MESSAGE = "parallel import of orjson running..." class Custom: pass def default(_): return None def func(_): orjson.dumps(Custom(), option=orjson.OPT_SERIALIZE_NUMPY, default=default) orjson.loads(b'{"a":1,"b":2,"c":3}') def main(): sys.stdout.write(TEST_MESSAGE) sys.stdout.flush() with multiprocessing.pool.ThreadPool(processes=NUM_PROC) as pool: pool.map(func, (i for i in range(0, NUM_PROC))) sys.stdout.write(f"\r{TEST_MESSAGE} ok\n") sys.stdout.flush() if __name__ == "__main__": main() orjson-3.9.15/integration/requirements.txt000066400000000000000000000001311456615046100207350ustar00rootroot00000000000000flask;sys_platform!="win" gunicorn;sys_platform!="win" httpx==0.24.1;sys_platform!="win" orjson-3.9.15/integration/run000077500000000000000000000010161456615046100162060ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail _dir="$(dirname "${BASH_SOURCE[0]}")" to_run="${@:-thread http init}" export PYTHONMALLOC="debug" if [[ $to_run == *"thread"* ]]; then "${_dir}"/thread fi if [[ $to_run == *"http"* ]]; then "${_dir}"/http --daemon sleep 2 "${_dir}"/client 8001 set +e pkill -f 'wsgi:app' # pkill not present on all CI envs set -e fi if [[ $to_run == *"typestubs"* ]]; then python "${_dir}"/typestubs.py mypy "${_dir}"/typestubs.py fi if [[ $to_run == *"init"* ]]; then "${_dir}"/init fi orjson-3.9.15/integration/thread000077500000000000000000000022241456615046100166530ustar00rootroot00000000000000#!/usr/bin/env python3 import sys import traceback from concurrent.futures import ThreadPoolExecutor from operator import itemgetter from threading import get_ident import orjson DATA = sorted( [ { "id": i, "name": "90as90ji0123ioj2390as90as90", "body": "哈哈89asu89as😊89as9as90jas-😋0apjzxiojzx89hq23n", "score": 901290129.1, "bool": True, "int": 9832, "none": None, } for i in range(10) ], key=itemgetter("id"), ) STATUS = 0 TEST_MESSAGE = "thread test running..." sys.stdout.write(TEST_MESSAGE) sys.stdout.flush() def test_func(n): try: assert sorted(orjson.loads(orjson.dumps(DATA)), key=itemgetter("id")) == DATA except Exception: traceback.print_exc() print("thread %s: %s dumps, loads ERROR" % (get_ident(), n)) with ThreadPoolExecutor(max_workers=4) as executor: executor.map(test_func, range(50000), chunksize=1000) executor.shutdown(wait=True) if STATUS == 0: sys.stdout.write(f"\r{TEST_MESSAGE} ok\n") else: sys.stdout.write(f"\r{TEST_MESSAGE} error\n") sys.exit(STATUS) orjson-3.9.15/integration/typestubs.py000066400000000000000000000002411456615046100200670ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson orjson.JSONDecodeError(msg="the_msg", doc="the_doc", pos=1) orjson.dumps(orjson.Fragment(b"{}")) orjson-3.9.15/integration/wsgi.py000066400000000000000000000011541456615046100170020ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from datetime import datetime, timezone from uuid import uuid4 from flask import Flask import orjson app = Flask(__name__) NOW = datetime.now(timezone.utc) @app.route("/") def root(): data = { "uuid": uuid4(), "updated_at": NOW, "data": [1, 2.2, None, True, False, orjson.Fragment(b"{}")], } payload = orjson.dumps( data, option=orjson.OPT_NAIVE_UTC | orjson.OPT_OMIT_MICROSECONDS ) return app.response_class( response=payload, status=200, mimetype="application/json; charset=utf-8", ) orjson-3.9.15/pyproject.toml000066400000000000000000000030611456615046100160470ustar00rootroot00000000000000[project] name = "orjson" repository = "https://github.com/ijl/orjson" requires-python = ">=3.8" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python", "Programming Language :: Rust", "Typing :: Typed", ] [project.urls] Changelog = "https://github.com/ijl/orjson/blob/master/CHANGELOG.md" [build-system] build-backend = "maturin" requires = ["maturin>=1,<2"] [tool.maturin] python-source = "pysrc" include = [ { format = "sdist", path = ".cargo/*" }, { format = "sdist", path = "build.rs" }, { format = "sdist", path = "Cargo.lock" }, { format = "sdist", path = "include/**/*" }, ] [tool.ruff] line-length = 88 target-version = "py38" [tool.ruff.lint] select = [ "I", ] ignore = [ "E501", # line too long "F601", # Dictionary key literal ... repeated ] [tool.ruff.lint.isort] known-first-party = ["orjson"] [tool.mypy] python_version = "3.8" orjson-3.9.15/pysrc/000077500000000000000000000000001456615046100142735ustar00rootroot00000000000000orjson-3.9.15/pysrc/orjson/000077500000000000000000000000001456615046100156055ustar00rootroot00000000000000orjson-3.9.15/pysrc/orjson/__init__.py000066400000000000000000000011151456615046100177140ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) from .orjson import * from .orjson import __version__ __all__ = ( "__version__", "dumps", "Fragment", "JSONDecodeError", "JSONEncodeError", "loads", "OPT_APPEND_NEWLINE", "OPT_INDENT_2", "OPT_NAIVE_UTC", "OPT_NON_STR_KEYS", "OPT_OMIT_MICROSECONDS", "OPT_PASSTHROUGH_DATACLASS", "OPT_PASSTHROUGH_DATETIME", "OPT_PASSTHROUGH_SUBCLASS", "OPT_SERIALIZE_DATACLASS", "OPT_SERIALIZE_NUMPY", "OPT_SERIALIZE_UUID", "OPT_SORT_KEYS", "OPT_STRICT_INTEGER", "OPT_UTC_Z", ) orjson-3.9.15/pysrc/orjson/__init__.pyi000066400000000000000000000013711456615046100200710ustar00rootroot00000000000000import json from typing import Any, Callable, Optional, Union __version__: str def dumps( __obj: Any, default: Optional[Callable[[Any], Any]] = ..., option: Optional[int] = ..., ) -> bytes: ... def loads(__obj: Union[bytes, bytearray, memoryview, str]) -> Any: ... class JSONDecodeError(json.JSONDecodeError): ... class JSONEncodeError(TypeError): ... class Fragment(tuple): contents: Union[bytes, str] OPT_APPEND_NEWLINE: int OPT_INDENT_2: int OPT_NAIVE_UTC: int OPT_NON_STR_KEYS: int OPT_OMIT_MICROSECONDS: int OPT_PASSTHROUGH_DATACLASS: int OPT_PASSTHROUGH_DATETIME: int OPT_PASSTHROUGH_SUBCLASS: int OPT_SERIALIZE_DATACLASS: int OPT_SERIALIZE_NUMPY: int OPT_SERIALIZE_UUID: int OPT_SORT_KEYS: int OPT_STRICT_INTEGER: int OPT_UTC_Z: int orjson-3.9.15/pysrc/orjson/py.typed000066400000000000000000000000001456615046100172720ustar00rootroot00000000000000orjson-3.9.15/requirements.txt000066400000000000000000000002431456615046100164160ustar00rootroot00000000000000-r bench/requirements.txt -r integration/requirements.txt -r test/requirements.txt maturin mypy ruff types-python-dateutil types-pytz types-simplejson types-ujson orjson-3.9.15/script/000077500000000000000000000000001456615046100144375ustar00rootroot00000000000000orjson-3.9.15/script/develop000077500000000000000000000007721456615046100160310ustar00rootroot00000000000000#!/bin/sh -e rm -f target/wheels/* export CC="${CC:-clang}" export LD="${LD:-lld}" echo "CC: ${CC}, LD: ${LD}, LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" export CFLAGS="-Os -fstrict-aliasing -emit-llvm -flto=full" export LDFLAGS="${CFLAGS} -fuse-ld=${LD} -Wl,--as-needed -Wl,-plugin-opt=also-emit-llvm" export RUSTFLAGS="-C linker=${CC} -C linker-plugin-lto -C lto=fat -C link-arg=-fuse-ld=${LD} -Z mir-opt-level=4 -Z virtual-function-elimination" maturin build "$@" pip install --force target/wheels/*.whl orjson-3.9.15/script/generate-yyjson000077500000000000000000000013301456615046100175050ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail _repo="$(dirname "$(dirname "${BASH_SOURCE[0]}")")" bindgen \ "${_repo}/include/yyjson/yyjson.h" \ --size_t-is-usize \ --disable-header-comment \ --no-derive-copy \ --no-derive-debug \ --no-doc-comments \ --no-layout-tests \ --allowlist-function=yyjson_alc_pool_init \ --allowlist-function=yyjson_doc_free \ --allowlist-function=yyjson_read_opts \ --allowlist-type=yyjson_alc \ --allowlist-type=yyjson_doc \ --allowlist-type=yyjson_read_code \ --allowlist-type=yyjson_read_err \ --allowlist-type=yyjson_val \ --allowlist-var=YYJSON_READ_NOFLAG \ --allowlist-var=YYJSON_READ_SUCCESS \ > "${_repo}/src/ffi/yyjson.rs" orjson-3.9.15/script/graph000077500000000000000000000101341456615046100154650ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections import io import os import pandas as pd import seaborn from matplotlib import pyplot from tabulate import tabulate import orjson LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") def aggregate(): benchmarks_dir = os.path.join(".benchmarks", os.listdir(".benchmarks")[0]) res = collections.defaultdict(dict) for filename in os.listdir(benchmarks_dir): with open(os.path.join(benchmarks_dir, filename), "r") as fileh: data = orjson.loads(fileh.read()) for each in data["benchmarks"]: res[each["group"]][each["extra_info"]["lib"]] = { "data": [val * 1000 for val in each["stats"]["data"]], "median": each["stats"]["median"] * 1000, "ops": each["stats"]["ops"], "correct": each["extra_info"]["correct"], } return res def tab(obj): buf = io.StringIO() headers = ( "Library", "Median latency (milliseconds)", "Operations per second", "Relative (latency)", ) seaborn.set_style("darkgrid") barplot_data = [] for group, val in sorted(obj.items(), reverse=True): buf.write("\n" + "#### " + group + "\n\n") table = [] for lib in LIBRARIES: correct = val[lib]["correct"] table.append( [ lib, val[lib]["median"] if correct else None, int(val[lib]["ops"]) if correct else None, 0, ] ) barplot_data.append( { "operation": "deserialization" if "deserialization" in group else "serialization", "group": group.strip("serialization") .strip("deserialization") .strip(), "library": lib, "latency": val[lib]["median"], "operations": int(val[lib]["ops"]) if correct else None, } ) orjson_baseline = table[0][1] for each in table: each[3] = ( "%.1f" % (each[1] / orjson_baseline) if isinstance(each[1], float) else None ) each[1] = "%.1f" % each[1] if isinstance(each[1], float) else None buf.write(tabulate(table, headers, tablefmt="github") + "\n") for operation in ("deserialization", "serialization"): per_op_data = list( (each for each in barplot_data if each["operation"] == operation) ) if not per_op_data: continue clamp = 10 if operation == "serialization" else 5 json_baseline = {} for each in per_op_data: if each["group"] == "witter.json": each["group"] = "twitter.json" if each["library"] == "json": json_baseline[each["group"]] = each["operations"] for each in per_op_data: each["relative"] = min( each["operations"] / json_baseline[each["group"]], clamp ) p = pd.DataFrame.from_dict(per_op_data) p.groupby("group") graph = seaborn.barplot( p, x="group", y="relative", orient="x", hue="library", errorbar="sd", legend="brief", ) graph.set_xlabel("Document") graph.set_ylabel("Operations/second relative to stdlib json") pyplot.title(operation) # ensure Y range ylabels = set((min(v, clamp) for v in pyplot.gca().get_yticks())) pyplot.gca().set_yticks(list({1.0, 1.5}.union(ylabels))) # print Y as percent pyplot.gca().set_yticklabels([f"{x:.0%}" for x in pyplot.gca().get_yticks()]) # reference for stdlib pyplot.axhline(y=1, color="#999", linestyle="dashed") pyplot.savefig(fname=f"doc/{operation}", dpi=300) pyplot.close() print(buf.getvalue()) tab(aggregate()) orjson-3.9.15/script/lint000077500000000000000000000006751456615046100153430ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail to_lint="./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py script/pydataclass script/pymem script/pysort script/pynumpy script/pynonstr script/pycorrectness script/graph integration/init integration/wsgi.py integration/typestubs.py integration/thread" ruff ${to_lint} --fix ruff format ${to_lint} mypy --ignore-missing-imports --check-untyped-defs ./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py orjson-3.9.15/script/profile000077500000000000000000000002231456615046100160220ustar00rootroot00000000000000#!/bin/sh -e # usage: ./profile data/citm_catalog.json.xz loads perf record -g --delay 250 ./bench/run_func "$@" perf report --percent-limit 0.1 orjson-3.9.15/script/pybench000077500000000000000000000004001456615046100160070ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail pytest \ --verbose \ --benchmark-min-time=1 \ --benchmark-max-time=5 \ --benchmark-disable-gc \ --benchmark-autosave \ --benchmark-save-data \ --random-order \ "bench/benchmark_$1.py" orjson-3.9.15/script/pybench-empty000077500000000000000000000004231456615046100171500ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail pytest \ --verbose \ --benchmark-min-time=1 \ --benchmark-max-time=5 \ --benchmark-disable-gc \ --benchmark-autosave \ --benchmark-save-data \ --random-order \ -k orjson \ "bench/benchmark_empty.py" orjson-3.9.15/script/pycorrectness000077500000000000000000000075161456615046100173010ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections import io import lzma import os from pathlib import Path from tabulate import tabulate import orjson dirname = os.path.join(os.path.dirname(__file__), "..", "data") LIBRARIES = ["orjson", "ujson", "rapidjson", "simplejson", "json"] def read_fixture_bytes(filename, subdir=None): if subdir is None: parts = (dirname, filename) else: parts = (dirname, subdir, filename) path = Path(*parts) if path.suffix == ".xz": contents = lzma.decompress(path.read_bytes()) else: contents = path.read_bytes() return contents PARSING = { filename: read_fixture_bytes(filename, "parsing") for filename in os.listdir("data/parsing") } JSONCHECKER = { filename: read_fixture_bytes(filename, "jsonchecker") for filename in os.listdir("data/jsonchecker") } RESULTS = collections.defaultdict(dict) def test_passed(library, fixture): passed = [] try: passed.append(library.loads(fixture) == orjson.loads(fixture)) passed.append( library.loads(fixture.decode("utf-8")) == orjson.loads(fixture.decode("utf-8")) ) except Exception: passed.append(False) return all(passed) def test_failed(library, fixture): rejected_as_bytes = False try: library.loads(fixture) except Exception: rejected_as_bytes = True rejected_as_str = False try: library.loads(fixture.decode("utf-8")) except Exception: rejected_as_str = True return rejected_as_bytes and rejected_as_str MISTAKEN_PASSES = {key: 0 for key in LIBRARIES} MISTAKEN_FAILS = {key: 0 for key in LIBRARIES} PASS_WHITELIST = ("fail01.json", "fail18.json") def should_pass(filename): return ( filename.startswith("y_") or filename.startswith("pass") or filename in PASS_WHITELIST ) def should_fail(filename): return ( filename.startswith("n_") or filename.startswith("i_string") or filename.startswith("i_object") or filename.startswith("fail") ) and filename not in PASS_WHITELIST for libname in LIBRARIES: library = __import__(libname) for fixture_set in (PARSING, JSONCHECKER): for filename, fixture in fixture_set.items(): if should_pass(filename): res = test_passed(library, fixture) RESULTS[filename][libname] = res if not res: MISTAKEN_PASSES[libname] += 1 elif should_fail(filename): res = test_failed(library, fixture) RESULTS[filename][libname] = res if not res: MISTAKEN_FAILS[libname] += 1 elif filename.startswith("i_"): continue else: raise NotImplementedError FILENAMES = sorted(list(PARSING.keys()) + list(JSONCHECKER.keys())) tab_results = [] for filename in FILENAMES: entry = [ filename, ] for libname in LIBRARIES: try: entry.append("ok" if RESULTS[filename][libname] else "fail") except KeyError: continue tab_results.append(entry) buf = io.StringIO() buf.write(tabulate(tab_results, ["Fixture"] + LIBRARIES, tablefmt="github")) buf.write("\n") print(buf.getvalue()) failure_results = [ [libname, MISTAKEN_FAILS[libname], MISTAKEN_PASSES[libname]] for libname in LIBRARIES ] buf = io.StringIO() buf.write( tabulate( failure_results, [ "Library", "Invalid JSON documents not rejected", "Valid JSON documents not deserialized", ], tablefmt="github", ) ) buf.write("\n") print(buf.getvalue()) num_results = len([each for each in tab_results if len(each) > 1]) print(f"{num_results} documents tested") orjson-3.9.15/script/pydataclass000077500000000000000000000066521456615046100167060ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import dataclasses import io import json import os from timeit import timeit from typing import List import rapidjson import simplejson import ujson from tabulate import tabulate import orjson os.sched_setaffinity(os.getpid(), {0, 1}) @dataclasses.dataclass class Member: id: int active: bool @dataclasses.dataclass class Object: id: int name: str members: List[Member] objects_as_dataclass = [ Object(i, str(i) * 3, [Member(j, True) for j in range(0, 10)]) for i in range(100000, 102000) ] objects_as_dict = [dataclasses.asdict(each) for each in objects_as_dataclass] output_in_kib = len(orjson.dumps(objects_as_dict)) / 1024 print(f"{output_in_kib:,.0f}KiB output (orjson)") def default(__obj): if dataclasses.is_dataclass(__obj): return dataclasses.asdict(__obj) headers = ("Library", "dict (ms)", "dataclass (ms)", "vs. orjson") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") ITERATIONS = 100 def per_iter_latency(val): if val is None: return None return (val * 1000) / ITERATIONS table = [] for lib_name in LIBRARIES: if lib_name == "json": as_dict = timeit( lambda: json.dumps(objects_as_dict).encode("utf-8"), number=ITERATIONS, ) as_dataclass = timeit( lambda: json.dumps(objects_as_dataclass, default=default).encode("utf-8"), number=ITERATIONS, ) elif lib_name == "simplejson": as_dict = timeit( lambda: simplejson.dumps(objects_as_dict).encode("utf-8"), number=ITERATIONS, ) as_dataclass = timeit( lambda: simplejson.dumps(objects_as_dataclass, default=default).encode( "utf-8" ), number=ITERATIONS, ) elif lib_name == "ujson": as_dict = timeit( lambda: ujson.dumps(objects_as_dict).encode("utf-8"), number=ITERATIONS, ) as_dataclass = None elif lib_name == "rapidjson": as_dict = timeit( lambda: rapidjson.dumps(objects_as_dict).encode("utf-8"), number=ITERATIONS, ) as_dataclass = timeit( lambda: rapidjson.dumps(objects_as_dataclass, default=default).encode( "utf-8" ), number=ITERATIONS, ) elif lib_name == "orjson": as_dict = timeit(lambda: orjson.dumps(objects_as_dict), number=ITERATIONS) as_dataclass = timeit( lambda: orjson.dumps( objects_as_dataclass, None, orjson.OPT_SERIALIZE_DATACLASS ), number=ITERATIONS, ) orjson_as_dataclass = per_iter_latency(as_dataclass) else: raise NotImplementedError as_dict = per_iter_latency(as_dict) as_dataclass = per_iter_latency(as_dataclass) if lib_name == "orjson": compared_to_orjson = 1 elif as_dataclass: compared_to_orjson = int(as_dataclass / orjson_as_dataclass) else: compared_to_orjson = None table.append( ( lib_name, f"{as_dict:,.2f}" if as_dict else "", f"{as_dataclass:,.2f}" if as_dataclass else "", f"{compared_to_orjson:d}" if compared_to_orjson else "", ) ) buf = io.StringIO() buf.write(tabulate(table, headers, tablefmt="github")) buf.write("\n") print(buf.getvalue()) orjson-3.9.15/script/pyindent000077500000000000000000000077051456615046100162300ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import io import json import lzma import os import sys from pathlib import Path from timeit import timeit import rapidjson import simplejson import ujson from tabulate import tabulate import orjson os.sched_setaffinity(os.getpid(), {0, 1}) dirname = os.path.join(os.path.dirname(__file__), "..", "data") def read_fixture_obj(filename): path = Path(dirname, filename) if path.suffix == ".xz": contents = lzma.decompress(path.read_bytes()) else: contents = path.read_bytes() return orjson.loads(contents) filename = sys.argv[1] if len(sys.argv) >= 1 else "" data = read_fixture_obj(f"{filename}.json.xz") headers = ("Library", "compact (ms)", "pretty (ms)", "vs. orjson") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") output_in_kib_compact = len(orjson.dumps(data)) / 1024 output_in_kib_pretty = len(orjson.dumps(data, option=orjson.OPT_INDENT_2)) / 1024 # minimum 2s runtime for orjson compact ITERATIONS = int(2 / (timeit(lambda: orjson.dumps(data), number=20) / 20)) print( f"{output_in_kib_compact:,.0f}KiB compact, {output_in_kib_pretty:,.0f}KiB pretty, {ITERATIONS} iterations" ) def per_iter_latency(val): if val is None: return None return (val * 1000) / ITERATIONS def test_correctness(serialized): return orjson.loads(serialized) == data table = [] for lib_name in LIBRARIES: print(f"{lib_name}...") if lib_name == "json": time_compact = timeit( lambda: json.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_pretty = timeit( lambda: json.dumps(data, indent=2).encode("utf-8"), number=ITERATIONS, ) correct = test_correctness(json.dumps(data, indent=2).encode("utf-8")) elif lib_name == "simplejson": time_compact = timeit( lambda: simplejson.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_pretty = timeit( lambda: simplejson.dumps(data, indent=2).encode("utf-8"), number=ITERATIONS, ) correct = test_correctness(simplejson.dumps(data, indent=2).encode("utf-8")) elif lib_name == "ujson": time_compact = timeit( lambda: ujson.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_pretty = timeit( lambda: ujson.dumps(data, indent=2).encode("utf-8"), number=ITERATIONS, ) correct = test_correctness(ujson.dumps(data, indent=2).encode("utf-8")) elif lib_name == "rapidjson": time_compact = timeit(lambda: rapidjson.dumps(data), number=ITERATIONS) time_pretty = timeit(lambda: rapidjson.dumps(data, indent=2), number=ITERATIONS) correct = test_correctness(rapidjson.dumps(data, indent=2)) elif lib_name == "orjson": time_compact = timeit(lambda: orjson.dumps(data), number=ITERATIONS) time_pretty = timeit( lambda: orjson.dumps(data, None, orjson.OPT_INDENT_2), number=ITERATIONS, ) correct = test_correctness(orjson.dumps(data, None, orjson.OPT_INDENT_2)) orjson_time_pretty = per_iter_latency(time_pretty) else: raise NotImplementedError time_compact = per_iter_latency(time_compact) if not correct: time_pretty = None else: time_pretty = per_iter_latency(time_pretty) if lib_name == "orjson": compared_to_orjson = 1 elif time_pretty: compared_to_orjson = time_pretty / orjson_time_pretty else: compared_to_orjson = None table.append( ( lib_name, f"{time_compact:,.2f}" if time_compact else "", f"{time_pretty:,.2f}" if time_pretty else "", f"{compared_to_orjson:,.1f}" if compared_to_orjson else "", ) ) buf = io.StringIO() buf.write(tabulate(table, headers, tablefmt="github")) buf.write("\n") print(buf.getvalue()) orjson-3.9.15/script/pymem000077500000000000000000000021261456615046100155150ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import io import subprocess from tabulate import tabulate buf = io.StringIO() headers = ("Library", "import, read() RSS (MiB)", "loads() increase in RSS (MiB)") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") FIXTURES = ("canada.json", "citm_catalog.json", "github.json", "twitter.json") for fixture in sorted(FIXTURES, reverse=True): table = [] buf.write("\n" + "#### " + fixture + "\n\n") for lib_name in LIBRARIES: proc = subprocess.Popen( ("bench/run_mem", f"data/{fixture}.xz", lib_name), stdout=subprocess.PIPE ) output = proc.stdout.readline().decode("utf-8").strip().split(",") mem_base = int(output[0]) / 1024 / 1024 mem_diff = int(output[1]) / 1024 / 1024 correct = bool(int(output[2])) if correct: table.append((lib_name, f"{mem_base:,.1f}", f"{mem_diff:,.1f}")) else: table.append((lib_name, "", "")) buf.write(tabulate(table, headers, tablefmt="github") + "\n") print(buf.getvalue()) orjson-3.9.15/script/pynonstr000077500000000000000000000102371456615046100162640ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import datetime import io import json import os import random from time import mktime from timeit import timeit import rapidjson import simplejson import ujson from tabulate import tabulate import orjson os.sched_setaffinity(os.getpid(), {0, 1}) data_as_obj = [] for year in range(1920, 2020): start = datetime.date(year, 1, 1) array = [ (int(mktime((start + datetime.timedelta(days=i)).timetuple())), i + 1) for i in range(0, 365) ] array.append(("other", 0)) random.shuffle(array) data_as_obj.append(dict(array)) data_as_str = orjson.loads(orjson.dumps(data_as_obj, option=orjson.OPT_NON_STR_KEYS)) headers = ("Library", "str keys (ms)", "int keys (ms)", "int keys sorted (ms)") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") ITERATIONS = 500 output_in_kib = len(orjson.dumps(data_as_str)) / 1024 print(f"{output_in_kib:,.0f}KiB output (orjson)") def per_iter_latency(val): if val is None: return None return (val * 1000) / ITERATIONS def test_correctness(serialized): return orjson.loads(serialized) == data_as_str table = [] for lib_name in LIBRARIES: print(f"{lib_name}...") if lib_name == "json": time_as_str = timeit( lambda: json.dumps(data_as_str).encode("utf-8"), number=ITERATIONS, ) time_as_obj = timeit( lambda: json.dumps(data_as_obj).encode("utf-8"), number=ITERATIONS, ) time_as_obj_sorted = ( None # TypeError: '<' not supported between instances of 'str' and 'int' ) correct = False elif lib_name == "simplejson": time_as_str = timeit( lambda: simplejson.dumps(data_as_str).encode("utf-8"), number=ITERATIONS, ) time_as_obj = timeit( lambda: simplejson.dumps(data_as_obj).encode("utf-8"), number=ITERATIONS, ) time_as_obj_sorted = timeit( lambda: simplejson.dumps(data_as_obj, sort_keys=True).encode("utf-8"), number=ITERATIONS, ) correct = test_correctness( simplejson.dumps(data_as_obj, sort_keys=True).encode("utf-8") ) elif lib_name == "ujson": time_as_str = timeit( lambda: ujson.dumps(data_as_str).encode("utf-8"), number=ITERATIONS, ) time_as_obj = timeit( lambda: ujson.dumps(data_as_obj).encode("utf-8"), number=ITERATIONS, ) time_as_obj_sorted = None # segfault correct = False elif lib_name == "rapidjson": time_as_str = timeit( lambda: rapidjson.dumps(data_as_str).encode("utf-8"), number=ITERATIONS, ) time_as_obj = None time_as_obj_sorted = None correct = False elif lib_name == "orjson": time_as_str = timeit( lambda: orjson.dumps(data_as_str, None, orjson.OPT_NON_STR_KEYS), number=ITERATIONS, ) time_as_obj = timeit( lambda: orjson.dumps(data_as_obj, None, orjson.OPT_NON_STR_KEYS), number=ITERATIONS, ) time_as_obj_sorted = timeit( lambda: orjson.dumps( data_as_obj, None, orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS ), number=ITERATIONS, ) correct = test_correctness( orjson.dumps( data_as_obj, None, orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS ) ) else: raise NotImplementedError time_as_str = per_iter_latency(time_as_str) time_as_obj = per_iter_latency(time_as_obj) if not correct: time_as_obj_sorted = None else: time_as_obj_sorted = per_iter_latency(time_as_obj_sorted) table.append( ( lib_name, f"{time_as_str:,.2f}" if time_as_str else "", f"{time_as_obj:,.2f}" if time_as_obj else "", f"{time_as_obj_sorted:,.2f}" if time_as_obj_sorted else "", ) ) buf = io.StringIO() buf.write(tabulate(table, headers, tablefmt="github")) buf.write("\n") print(buf.getvalue()) orjson-3.9.15/script/pynumpy000077500000000000000000000067651456615046100161240ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import gc import io import json import os import sys import time from timeit import timeit import numpy import psutil import rapidjson import simplejson from memory_profiler import memory_usage from tabulate import tabulate import orjson os.sched_setaffinity(os.getpid(), {0, 1}) kind = sys.argv[1] if len(sys.argv) >= 1 else "" if kind == "int32": array = numpy.random.randint(((2**31) - 1), size=(100000, 100), dtype=numpy.int32) elif kind == "float64": array = numpy.random.random(size=(50000, 100)) assert array.dtype == numpy.float64 elif kind == "bool": array = numpy.random.choice((True, False), size=(100000, 200)) elif kind == "int8": array = numpy.random.randint(((2**7) - 1), size=(100000, 100), dtype=numpy.int8) elif kind == "int16": array = numpy.random.randint(((2**15) - 1), size=(100000, 100), dtype=numpy.int16) elif kind == "int32": array = numpy.random.randint(((2**31) - 1), size=(100000, 100), dtype=numpy.int32) elif kind == "uint8": array = numpy.random.randint(((2**8) - 1), size=(100000, 100), dtype=numpy.uint8) elif kind == "uint16": array = numpy.random.randint(((2**16) - 1), size=(100000, 100), dtype=numpy.uint16) else: print("usage: pynumpy (bool|int16|int32|float64|int8|uint8|uint16)") sys.exit(1) proc = psutil.Process() def default(__obj): if isinstance(__obj, numpy.ndarray): return __obj.tolist() headers = ("Library", "Latency (ms)", "RSS diff (MiB)", "vs. orjson") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") ITERATIONS = 10 def orjson_dumps(): return orjson.dumps(array, option=orjson.OPT_SERIALIZE_NUMPY) ujson_dumps = None def rapidjson_dumps(): return rapidjson.dumps(array, default=default).encode("utf-8") def simplejson_dumps(): return simplejson.dumps(array, default=default).encode("utf-8") def json_dumps(): return json.dumps(array, default=default).encode("utf-8") output_in_mib = len(orjson_dumps()) / 1024 / 1024 print(f"{output_in_mib:,.1f}MiB {kind} output (orjson)") gc.collect() mem_before = proc.memory_full_info().rss / 1024 / 1024 def per_iter_latency(val): if val is None: return None return (val * 1000) / ITERATIONS def test_correctness(func): return orjson.loads(func()) == array.tolist() table = [] for lib_name in LIBRARIES: gc.collect() print(f"{lib_name}...") func = locals()[f"{lib_name}_dumps"] if func is None: total_latency = None latency = None mem = None correct = False else: total_latency = timeit( func, number=ITERATIONS, ) latency = per_iter_latency(total_latency) time.sleep(1) mem = max(memory_usage((func,), interval=0.001, timeout=latency * 2)) correct = test_correctness(func) if lib_name == "orjson": compared_to_orjson = 1 orjson_latency = latency elif latency: compared_to_orjson = latency / orjson_latency else: compared_to_orjson = None if not correct: latency = None mem = 0 mem_diff = mem - mem_before table.append( ( lib_name, f"{latency:,.0f}" if latency else "", f"{mem_diff:,.0f}" if mem else "", f"{compared_to_orjson:,.1f}" if (latency and compared_to_orjson) else "", ) ) buf = io.StringIO() buf.write(tabulate(table, headers, tablefmt="github")) buf.write("\n") print(buf.getvalue()) orjson-3.9.15/script/pysort000077500000000000000000000061631456615046100157330ustar00rootroot00000000000000#!/usr/bin/env python3 # SPDX-License-Identifier: (Apache-2.0 OR MIT) import io import json import lzma import os from pathlib import Path from timeit import timeit import rapidjson import simplejson import ujson from tabulate import tabulate import orjson os.sched_setaffinity(os.getpid(), {0, 1}) dirname = os.path.join(os.path.dirname(__file__), "..", "data") def read_fixture_obj(filename): path = Path(dirname, filename) if path.suffix == ".xz": contents = lzma.decompress(path.read_bytes()) else: contents = path.read_bytes() return orjson.loads(contents) data = read_fixture_obj("twitter.json.xz") headers = ("Library", "unsorted (ms)", "sorted (ms)", "vs. orjson") LIBRARIES = ("orjson", "ujson", "rapidjson", "simplejson", "json") ITERATIONS = 500 def per_iter_latency(val): if val is None: return None return (val * 1000) / ITERATIONS table = [] for lib_name in LIBRARIES: if lib_name == "json": time_unsorted = timeit( lambda: json.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_sorted = timeit( lambda: json.dumps(data, sort_keys=True).encode("utf-8"), number=ITERATIONS, ) elif lib_name == "simplejson": time_unsorted = timeit( lambda: simplejson.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_sorted = timeit( lambda: simplejson.dumps(data, sort_keys=True).encode("utf-8"), number=ITERATIONS, ) elif lib_name == "ujson": time_unsorted = timeit( lambda: ujson.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_sorted = timeit( lambda: ujson.dumps(data, sort_keys=True).encode("utf-8"), number=ITERATIONS, ) elif lib_name == "rapidjson": time_unsorted = timeit( lambda: rapidjson.dumps(data).encode("utf-8"), number=ITERATIONS, ) time_sorted = timeit( lambda: rapidjson.dumps(data, sort_keys=True).encode("utf-8"), number=ITERATIONS, ) elif lib_name == "orjson": time_unsorted = timeit(lambda: orjson.dumps(data), number=ITERATIONS) time_sorted = timeit( lambda: orjson.dumps(data, None, orjson.OPT_SORT_KEYS), number=ITERATIONS, ) orjson_time_sorted = per_iter_latency(time_sorted) else: raise NotImplementedError time_unsorted = per_iter_latency(time_unsorted) time_sorted = per_iter_latency(time_sorted) if lib_name == "orjson": compared_to_orjson = 1 elif time_unsorted: compared_to_orjson = time_sorted / orjson_time_sorted else: compared_to_orjson = None table.append( ( lib_name, f"{time_unsorted:,.2f}" if time_unsorted else "", f"{time_sorted:,.2f}" if time_sorted else "", f"{compared_to_orjson:,.1f}" if compared_to_orjson else "", ) ) buf = io.StringIO() buf.write(tabulate(table, headers, tablefmt="github")) buf.write("\n") print(buf.getvalue()) orjson-3.9.15/script/pytest000077500000000000000000000001061456615046100157120ustar00rootroot00000000000000#!/bin/sh -e PYTHONMALLOC="debug" pytest -s -rxX --random-order test orjson-3.9.15/script/vendor-yyjson000077500000000000000000000024471456615046100172220ustar00rootroot00000000000000#!/usr/bin/env bash set -eou pipefail yyjson_version="0eca326fe57aeeb866e6f04c9ef9ea9f8343157e" curl -Ls -o include/yyjson/yyjson.c "https://raw.githubusercontent.com/ibireme/yyjson/${yyjson_version}/src/yyjson.c" curl -Ls -o include/yyjson/yyjson.h "https://raw.githubusercontent.com/ibireme/yyjson/${yyjson_version}/src/yyjson.h" sed -i 's/yyjson_api_inline void yyjson_doc_free/yyjson_api void yyjson_doc_free/g' include/yyjson/yyjson.h sed -i 's/(flg & (YYJSON_READ_NUMBER_AS_RAW | YYJSON_READ_BIGNUM_AS_RAW)) != 0/false/g' include/yyjson/yyjson.c sed -i 's/if (pre)/if (false)/g' include/yyjson/yyjson.c sed -i 's/!false/true/g' include/yyjson/yyjson.c sed -i 's/ && true//g' include/yyjson/yyjson.c sed -i 's/true && //g' include/yyjson/yyjson.c sed -i 's/unlikely(false)/false/g' include/yyjson/yyjson.c sed -i 's/YYJSON_TYPE_STR | YYJSON_SUBTYPE_NOESC/YYJSON_TYPE_STR/g' include/yyjson/yyjson.c sed -i 's/unlikely(pos == src)/false/g' include/yyjson/yyjson.c sed -i 's/ yyjson_read_err dummy_err;//g' include/yyjson/yyjson.c sed -i 's/ if (!err) err = &dummy_err;//g' include/yyjson/yyjson.c sed -i 's/likely(!alc_ptr)/!alc_ptr/g' include/yyjson/yyjson.c sed -i 's/unlikely(read_flag_eq(flg, YYJSON_READ_##_flag))/false/g' include/yyjson/yyjson.c git apply include/yyjson-recursion-limit.patch orjson-3.9.15/src/000077500000000000000000000000001456615046100137225ustar00rootroot00000000000000orjson-3.9.15/src/deserialize/000077500000000000000000000000001456615046100162225ustar00rootroot00000000000000orjson-3.9.15/src/deserialize/cache.rs000066400000000000000000000024751456615046100176430ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use associative_cache::{AssociativeCache, Capacity1024, HashDirectMapped, RoundRobinReplacement}; use core::ffi::c_void; use once_cell::unsync::OnceCell; use std::hash::Hasher; #[repr(transparent)] pub struct CachedKey { ptr: *mut c_void, } unsafe impl Send for CachedKey {} unsafe impl Sync for CachedKey {} impl CachedKey { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> CachedKey { CachedKey { ptr: ptr as *mut c_void, } } pub fn get(&mut self) -> *mut pyo3_ffi::PyObject { let ptr = self.ptr as *mut pyo3_ffi::PyObject; debug_assert!(ffi!(Py_REFCNT(ptr)) >= 1); ffi!(Py_INCREF(ptr)); ptr } } impl Drop for CachedKey { fn drop(&mut self) { ffi!(Py_DECREF(self.ptr as *mut pyo3_ffi::PyObject)); } } pub type KeyMap = AssociativeCache; pub static mut KEY_MAP: OnceCell = OnceCell::new(); pub fn cache_hash(key: &[u8]) -> u64 { // try to omit code for >64 path in ahash debug_assert!(key.len() <= 64); #[cfg(feature = "intrinsics")] unsafe { core::intrinsics::assume(key.len() <= 64); }; let mut hasher = ahash::AHasher::default(); hasher.write(key); hasher.finish() } orjson-3.9.15/src/deserialize/deserializer.rs000066400000000000000000000020271456615046100212530ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::deserialize::utf8::read_input_to_buf; use crate::deserialize::DeserializeError; use crate::typeref::EMPTY_UNICODE; use core::ptr::NonNull; pub fn deserialize( ptr: *mut pyo3_ffi::PyObject, ) -> Result, DeserializeError<'static>> { debug_assert!(ffi!(Py_REFCNT(ptr)) >= 1); let buffer = read_input_to_buf(ptr)?; if unlikely!(buffer.len() == 2) { if buffer == b"[]" { return Ok(nonnull!(ffi!(PyList_New(0)))); } else if buffer == b"{}" { return Ok(nonnull!(ffi!(PyDict_New()))); } else if buffer == b"\"\"" { unsafe { return Ok(nonnull!(use_immortal!(EMPTY_UNICODE))) } } } let buffer_str = unsafe { std::str::from_utf8_unchecked(buffer) }; #[cfg(feature = "yyjson")] { crate::deserialize::yyjson::deserialize_yyjson(buffer_str) } #[cfg(not(feature = "yyjson"))] { crate::deserialize::json::deserialize_json(buffer_str) } } orjson-3.9.15/src/deserialize/error.rs000066400000000000000000000060741456615046100177300ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use std::borrow::Cow; pub struct DeserializeError<'a> { pub message: Cow<'a, str>, #[cfg(not(feature = "yyjson"))] pub line: usize, // start at 1 #[cfg(not(feature = "yyjson"))] pub column: usize, // start at 1 pub data: Option<&'a str>, pub pos: i64, } impl<'a> DeserializeError<'a> { #[cold] pub fn invalid(message: Cow<'a, str>) -> Self { DeserializeError { message: message, #[cfg(not(feature = "yyjson"))] line: 0, #[cfg(not(feature = "yyjson"))] column: 0, data: None, pos: 0, } } #[cold] #[cfg(not(feature = "yyjson"))] pub fn from_json(message: Cow<'a, str>, line: usize, column: usize, data: &'a str) -> Self { DeserializeError { message, line, column, data: Some(data), pos: 0, } } #[cold] #[cfg(feature = "yyjson")] pub fn from_yyjson(message: Cow<'a, str>, pos: i64, data: &'a str) -> Self { DeserializeError { message: message, data: Some(data), pos: pos, } } /// Return position of the error in the deserialized data #[cold] #[cfg(feature = "yyjson")] #[cfg_attr(feature = "optimize", optimize(size))] pub fn pos(&self) -> i64 { match self.data { Some(as_str) => as_str[0..self.pos as usize].chars().count() as i64, None => 0, } } /// Return position of the error in the deserialized data #[cold] #[cfg(not(feature = "yyjson"))] #[cfg_attr(feature = "optimize", optimize(size))] pub fn pos(&self) -> i64 { if self.line == 0 || self.data.is_none() { return 1; } let val = self.data.unwrap() .split('\n') // take only the relevant lines .take(self.line) .enumerate() .map(|(idx, s)| { if idx == self.line - 1 { // Last line: only characters until the column of the error are relevant. // Note: Rust uses bytes whereas Python uses chars: we hence cannot // directly use the `column` field if self.column == 0 { return 0; } // Find a column we can safely slice on let mut column = self.column - 1; while column > 0 && !s.is_char_boundary(column) { column -= 1; } let chars_count = s[..column].chars().count(); if chars_count == s.chars().count() - 1 { chars_count + 1 } else { chars_count } } else { // Other lines s.chars().count() } }) .sum::() // add missed '\n' characters + (self.line - 1); val as i64 } } orjson-3.9.15/src/deserialize/json.rs000066400000000000000000000077311456615046100175510ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::deserialize::pyobject::*; use crate::deserialize::DeserializeError; use crate::str::unicode_from_str; use core::ptr::NonNull; use serde::de::{self, DeserializeSeed, Deserializer, MapAccess, SeqAccess, Visitor}; use smallvec::SmallVec; use std::borrow::Cow; use std::fmt; pub fn deserialize_json( data: &'static str, ) -> Result, DeserializeError<'static>> { let mut deserializer = serde_json::Deserializer::from_str(data); let seed = JsonValue {}; match seed.deserialize(&mut deserializer) { Ok(obj) => { deserializer.end().map_err(|e| { DeserializeError::from_json(Cow::Owned(e.to_string()), e.line(), e.column(), data) })?; Ok(obj) } Err(e) => Err(DeserializeError::from_json( Cow::Owned(e.to_string()), e.line(), e.column(), data, )), } } #[derive(Clone, Copy)] struct JsonValue; impl<'de> DeserializeSeed<'de> for JsonValue { type Value = NonNull; fn deserialize(self, deserializer: D) -> Result where D: Deserializer<'de>, { deserializer.deserialize_any(self) } } impl<'de> Visitor<'de> for JsonValue { type Value = NonNull; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("JSON") } fn visit_unit(self) -> Result { Ok(parse_none()) } fn visit_bool(self, value: bool) -> Result where E: de::Error, { Ok(parse_bool(value)) } fn visit_i64(self, value: i64) -> Result where E: de::Error, { Ok(parse_i64(value)) } fn visit_u64(self, value: u64) -> Result where E: de::Error, { Ok(parse_u64(value)) } fn visit_f64(self, value: f64) -> Result where E: de::Error, { Ok(parse_f64(value)) } fn visit_borrowed_str(self, value: &str) -> Result where E: de::Error, { Ok(nonnull!(unicode_from_str(value))) } fn visit_str(self, value: &str) -> Result where E: de::Error, { Ok(nonnull!(unicode_from_str(value))) } fn visit_seq(self, mut seq: A) -> Result where A: SeqAccess<'de>, { match seq.next_element_seed(self) { Ok(None) => Ok(nonnull!(ffi!(PyList_New(0)))), Ok(Some(elem)) => { let mut elements: SmallVec<[*mut pyo3_ffi::PyObject; 8]> = SmallVec::with_capacity(8); elements.push(elem.as_ptr()); while let Some(elem) = seq.next_element_seed(self)? { elements.push(elem.as_ptr()); } let ptr = ffi!(PyList_New(elements.len() as isize)); for (i, &obj) in elements.iter().enumerate() { ffi!(PyList_SET_ITEM(ptr, i as isize, obj)); } Ok(nonnull!(ptr)) } Err(err) => Result::Err(err), } } fn visit_map(self, mut map: A) -> Result where A: MapAccess<'de>, { let dict_ptr = ffi!(PyDict_New()); while let Some(key) = map.next_key::>()? { let pykey = get_unicode_key(&key); let pyval = map.next_value_seed(self)?; let _ = unsafe { pyo3_ffi::_PyDict_SetItem_KnownHash( dict_ptr, pykey, pyval.as_ptr(), str_hash!(pykey), ) }; reverse_pydict_incref!(pykey); reverse_pydict_incref!(pyval.as_ptr()); } Ok(nonnull!(dict_ptr)) } } orjson-3.9.15/src/deserialize/mod.rs000066400000000000000000000004701456615046100173500ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) mod cache; mod deserializer; mod error; mod pyobject; mod utf8; #[cfg(not(feature = "yyjson"))] mod json; #[cfg(feature = "yyjson")] mod yyjson; pub use cache::KeyMap; pub use cache::KEY_MAP; pub use deserializer::deserialize; pub use error::DeserializeError; orjson-3.9.15/src/deserialize/pyobject.rs000066400000000000000000000036551456615046100204200ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::deserialize::cache::*; use crate::str::{hash_str, unicode_from_str}; use crate::typeref::{FALSE, NONE, TRUE}; use core::ptr::NonNull; pub fn get_unicode_key(key_str: &str) -> *mut pyo3_ffi::PyObject { let pykey = if unlikely!(key_str.len() > 64) { create_str_impl(key_str) } else { get_unicode_key_impl(key_str) }; debug_assert!(ffi!(Py_REFCNT(pykey)) >= 1); debug_assert!(unsafe { (*pykey.cast::()).hash != -1 }); pykey } fn get_unicode_key_impl(key_str: &str) -> *mut pyo3_ffi::PyObject { let hash = cache_hash(key_str.as_bytes()); let map = unsafe { KEY_MAP.get_mut().unwrap_or_else(|| unreachable!()) }; let entry = map.entry(&hash).or_insert_with( || hash, || { let pyob = create_str_impl(key_str); CachedKey::new(pyob) }, ); entry.get() } fn create_str_impl(key_str: &str) -> *mut pyo3_ffi::PyObject { let pyob = unicode_from_str(key_str); hash_str(pyob); pyob } #[allow(dead_code)] #[inline(always)] pub fn parse_bool(val: bool) -> NonNull { if val { parse_true() } else { parse_false() } } #[inline(always)] pub fn parse_true() -> NonNull { nonnull!(use_immortal!(TRUE)) } #[inline(always)] pub fn parse_false() -> NonNull { nonnull!(use_immortal!(FALSE)) } #[inline(always)] pub fn parse_i64(val: i64) -> NonNull { nonnull!(ffi!(PyLong_FromLongLong(val))) } #[inline(always)] pub fn parse_u64(val: u64) -> NonNull { nonnull!(ffi!(PyLong_FromUnsignedLongLong(val))) } #[inline(always)] pub fn parse_f64(val: f64) -> NonNull { nonnull!(ffi!(PyFloat_FromDouble(val))) } #[inline(always)] pub fn parse_none() -> NonNull { nonnull!(use_immortal!(NONE)) } orjson-3.9.15/src/deserialize/utf8.rs000066400000000000000000000062741456615046100174670ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::deserialize::DeserializeError; use crate::ffi::*; use crate::str::unicode_to_str; use crate::typeref::{BYTEARRAY_TYPE, BYTES_TYPE, MEMORYVIEW_TYPE, STR_TYPE}; use crate::util::INVALID_STR; use core::ffi::c_char; use std::borrow::Cow; #[cfg(all(target_arch = "x86_64", not(target_feature = "sse4.2")))] fn is_valid_utf8(buf: &[u8]) -> bool { if std::is_x86_feature_detected!("sse4.2") { simdutf8::basic::from_utf8(buf).is_ok() } else { encoding_rs::Encoding::utf8_valid_up_to(buf) == buf.len() } } #[cfg(all(target_arch = "x86_64", target_feature = "sse4.2"))] fn is_valid_utf8(buf: &[u8]) -> bool { simdutf8::basic::from_utf8(buf).is_ok() } #[cfg(target_arch = "aarch64")] fn is_valid_utf8(buf: &[u8]) -> bool { simdutf8::basic::from_utf8(buf).is_ok() } #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] fn is_valid_utf8(buf: &[u8]) -> bool { std::str::from_utf8(buf).is_ok() } pub fn read_input_to_buf( ptr: *mut pyo3_ffi::PyObject, ) -> Result<&'static [u8], DeserializeError<'static>> { let obj_type_ptr = ob_type!(ptr); let buffer: &[u8]; if is_type!(obj_type_ptr, BYTES_TYPE) { buffer = unsafe { core::slice::from_raw_parts( PyBytes_AS_STRING(ptr) as *const u8, PyBytes_GET_SIZE(ptr) as usize, ) }; if !is_valid_utf8(buffer) { return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR))); } } else if is_type!(obj_type_ptr, STR_TYPE) { let uni = unicode_to_str(ptr); if unlikely!(uni.is_none()) { return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR))); } let as_str = uni.unwrap(); buffer = unsafe { core::slice::from_raw_parts(as_str.as_ptr(), as_str.len()) }; } else if unlikely!(is_type!(obj_type_ptr, MEMORYVIEW_TYPE)) { let membuf = unsafe { PyMemoryView_GET_BUFFER(ptr) }; if unsafe { pyo3_ffi::PyBuffer_IsContiguous(membuf, b'C' as c_char) == 0 } { return Err(DeserializeError::invalid(Cow::Borrowed( "Input type memoryview must be a C contiguous buffer", ))); } buffer = unsafe { core::slice::from_raw_parts((*membuf).buf as *const u8, (*membuf).len as usize) }; if !is_valid_utf8(buffer) { return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR))); } } else if unlikely!(is_type!(obj_type_ptr, BYTEARRAY_TYPE)) { buffer = unsafe { core::slice::from_raw_parts( ffi!(PyByteArray_AsString(ptr)) as *const u8, ffi!(PyByteArray_Size(ptr)) as usize, ) }; if !is_valid_utf8(buffer) { return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR))); } } else { return Err(DeserializeError::invalid(Cow::Borrowed( "Input must be bytes, bytearray, memoryview, or str", ))); } if unlikely!(buffer.is_empty()) { Err(DeserializeError::invalid(Cow::Borrowed( "Input is a zero-length, empty document", ))) } else { Ok(buffer) } } orjson-3.9.15/src/deserialize/yyjson.rs000066400000000000000000000134521456615046100201300ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::deserialize::pyobject::*; use crate::deserialize::DeserializeError; use crate::ffi::yyjson::*; use crate::str::unicode_from_str; use crate::typeref::{yyjson_init, YYJSON_ALLOC, YYJSON_BUFFER_SIZE}; use core::ffi::c_char; use core::ptr::{null, null_mut, NonNull}; use std::borrow::Cow; const YYJSON_TAG_BIT: u8 = 8; const YYJSON_VAL_SIZE: usize = core::mem::size_of::(); const TAG_ARRAY: u8 = 0b00000110; const TAG_DOUBLE: u8 = 0b00010100; const TAG_FALSE: u8 = 0b00000011; const TAG_INT64: u8 = 0b00001100; const TAG_NULL: u8 = 0b00000010; const TAG_OBJECT: u8 = 0b00000111; const TAG_STRING: u8 = 0b00000101; const TAG_TRUE: u8 = 0b00001011; const TAG_UINT64: u8 = 0b00000100; fn yyjson_doc_get_root(doc: *mut yyjson_doc) -> *mut yyjson_val { unsafe { (*doc).root } } fn unsafe_yyjson_get_len(val: *mut yyjson_val) -> usize { unsafe { ((*val).tag >> YYJSON_TAG_BIT) as usize } } fn unsafe_yyjson_get_first(ctn: *mut yyjson_val) -> *mut yyjson_val { unsafe { ctn.add(1) } } fn yyjson_read_max_memory_usage(len: usize) -> usize { (12 * len) + 256 } fn unsafe_yyjson_is_ctn(val: *mut yyjson_val) -> bool { unsafe { ((*val).tag as u8) & 0b00000110 == 0b00000110 } } fn unsafe_yyjson_get_next(val: *mut yyjson_val) -> *mut yyjson_val { unsafe { if unlikely!(unsafe_yyjson_is_ctn(val)) { ((val as *mut u8).add((*val).uni.ofs)) as *mut yyjson_val } else { ((val as *mut u8).add(YYJSON_VAL_SIZE)) as *mut yyjson_val } } } pub fn deserialize_yyjson( data: &'static str, ) -> Result, DeserializeError<'static>> { let mut err = yyjson_read_err { code: YYJSON_READ_SUCCESS, msg: null(), pos: 0, }; let doc = if yyjson_read_max_memory_usage(data.len()) < YYJSON_BUFFER_SIZE { read_doc_with_buffer(data, &mut err) } else { read_doc_default(data, &mut err) }; if unlikely!(doc.is_null()) { let msg: Cow = unsafe { core::ffi::CStr::from_ptr(err.msg).to_string_lossy() }; Err(DeserializeError::from_yyjson(msg, err.pos as i64, data)) } else { let root = yyjson_doc_get_root(doc); let ret = parse_node(root); unsafe { yyjson_doc_free(doc) }; Ok(ret) } } fn read_doc_default(data: &'static str, err: &mut yyjson_read_err) -> *mut yyjson_doc { unsafe { yyjson_read_opts( data.as_ptr() as *mut c_char, data.len(), YYJSON_READ_NOFLAG, null_mut(), err, ) } } fn read_doc_with_buffer(data: &'static str, err: &mut yyjson_read_err) -> *mut yyjson_doc { unsafe { yyjson_read_opts( data.as_ptr() as *mut c_char, data.len(), YYJSON_READ_NOFLAG, &YYJSON_ALLOC.get_or_init(yyjson_init).alloc, err, ) } } enum ElementType { String, Uint64, Int64, Double, Null, True, False, Array, Object, } impl ElementType { fn from_tag(elem: *mut yyjson_val) -> Self { match unsafe { (*elem).tag as u8 } { TAG_STRING => Self::String, TAG_UINT64 => Self::Uint64, TAG_INT64 => Self::Int64, TAG_DOUBLE => Self::Double, TAG_NULL => Self::Null, TAG_TRUE => Self::True, TAG_FALSE => Self::False, TAG_ARRAY => Self::Array, TAG_OBJECT => Self::Object, _ => unreachable!(), } } } fn parse_yy_string(elem: *mut yyjson_val) -> NonNull { nonnull!(unicode_from_str(str_from_slice!( (*elem).uni.str_ as *const u8, unsafe_yyjson_get_len(elem) ))) } #[inline(never)] fn parse_yy_array(elem: *mut yyjson_val) -> NonNull { unsafe { let len = unsafe_yyjson_get_len(elem); let list = ffi!(PyList_New(len as isize)); if len == 0 { return nonnull!(list); } let mut cur = unsafe_yyjson_get_first(elem); for idx in 0..=len - 1 { let next = unsafe_yyjson_get_next(cur); let val = parse_node(cur).as_ptr(); ffi!(PyList_SET_ITEM(list, idx as isize, val)); cur = next; } nonnull!(list) } } #[inline(never)] fn parse_yy_object(elem: *mut yyjson_val) -> NonNull { unsafe { let len = unsafe_yyjson_get_len(elem); if len == 0 { return nonnull!(ffi!(PyDict_New())); } let mut key = unsafe_yyjson_get_first(elem); let dict = ffi!(_PyDict_NewPresized(len as isize)); for _ in 0..=len - 1 { let val = key.add(1); let key_str = str_from_slice!((*key).uni.str_ as *const u8, unsafe_yyjson_get_len(key)); let pykey = get_unicode_key(key_str); let pyval = parse_node(val).as_ptr(); key = unsafe_yyjson_get_next(val); let _ = unsafe { pyo3_ffi::_PyDict_SetItem_KnownHash(dict, pykey, pyval, str_hash!(pykey)) }; reverse_pydict_incref!(pykey); reverse_pydict_incref!(pyval); } nonnull!(dict) } } pub fn parse_node(elem: *mut yyjson_val) -> NonNull { match ElementType::from_tag(elem) { ElementType::String => parse_yy_string(elem), ElementType::Uint64 => parse_u64(unsafe { (*elem).uni.u64_ }), ElementType::Int64 => parse_i64(unsafe { (*elem).uni.i64_ }), ElementType::Double => parse_f64(unsafe { (*elem).uni.f64_ }), ElementType::Null => parse_none(), ElementType::True => parse_true(), ElementType::False => parse_false(), ElementType::Array => parse_yy_array(elem), ElementType::Object => parse_yy_object(elem), } } orjson-3.9.15/src/ffi/000077500000000000000000000000001456615046100144665ustar00rootroot00000000000000orjson-3.9.15/src/ffi/buffer.rs000066400000000000000000000013241456615046100163050ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::c_int; use pyo3_ffi::*; #[repr(C)] pub struct _PyManagedBufferObject { pub ob_base: *mut pyo3_ffi::PyObject, pub flags: c_int, pub exports: Py_ssize_t, pub master: *mut Py_buffer, } #[repr(C)] pub struct PyMemoryViewObject { pub ob_base: PyVarObject, pub mbuf: *mut _PyManagedBufferObject, pub hash: Py_hash_t, pub flags: c_int, pub exports: Py_ssize_t, pub view: Py_buffer, pub weakreflist: *mut PyObject, pub ob_array: [Py_ssize_t; 1], } #[allow(non_snake_case)] #[inline(always)] pub unsafe fn PyMemoryView_GET_BUFFER(op: *mut PyObject) -> *const Py_buffer { &(*op.cast::()).view } orjson-3.9.15/src/ffi/bytes.rs000066400000000000000000000007221456615046100161630ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::c_char; use pyo3_ffi::{PyBytesObject, PyObject, PyVarObject, Py_ssize_t}; #[allow(non_snake_case)] #[inline(always)] pub unsafe fn PyBytes_AS_STRING(op: *mut PyObject) -> *const c_char { &(*op.cast::()).ob_sval as *const c_char } #[allow(non_snake_case)] #[inline(always)] pub unsafe fn PyBytes_GET_SIZE(op: *mut PyObject) -> Py_ssize_t { (*op.cast::()).ob_size } orjson-3.9.15/src/ffi/fragment.rs000066400000000000000000000077551456615046100166550ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::{c_char, c_ulong}; use core::ptr::null_mut; use pyo3_ffi::*; // https://docs.python.org/3/c-api/typeobj.html#typedef-examples #[repr(C)] pub struct Fragment { pub ob_refcnt: pyo3_ffi::Py_ssize_t, pub ob_type: *mut pyo3_ffi::PyTypeObject, pub contents: *mut pyo3_ffi::PyObject, } #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn raise_args_exception() -> *mut PyObject { unsafe { let msg = "orjson.Fragment() takes exactly 1 positional argument"; let err_msg = PyUnicode_FromStringAndSize(msg.as_ptr() as *const c_char, msg.len() as isize); PyErr_SetObject(PyExc_TypeError, err_msg); Py_DECREF(err_msg); }; null_mut() } #[no_mangle] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub unsafe extern "C" fn orjson_fragment_tp_new( _subtype: *mut PyTypeObject, args: *mut PyObject, kwds: *mut PyObject, ) -> *mut PyObject { if Py_SIZE(args) != 1 || !kwds.is_null() { raise_args_exception(); null_mut() } else { let contents = PyTuple_GET_ITEM(args, 0); Py_INCREF(contents); let obj = Box::new(Fragment { ob_refcnt: 1, ob_type: crate::typeref::FRAGMENT_TYPE, contents: contents, }); Box::into_raw(obj) as *mut PyObject } } #[no_mangle] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub unsafe extern "C" fn orjson_fragment_dealloc(object: *mut PyObject) { Py_DECREF((*(object as *mut Fragment)).contents); std::alloc::dealloc(object as *mut u8, std::alloc::Layout::new::()); } #[cfg(Py_3_10)] const FRAGMENT_TP_FLAGS: c_ulong = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE; #[cfg(not(Py_3_10))] const FRAGMENT_TP_FLAGS: c_ulong = Py_TPFLAGS_DEFAULT; #[no_mangle] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub unsafe extern "C" fn orjson_fragmenttype_new() -> *mut PyTypeObject { let ob = Box::new(PyTypeObject { ob_base: PyVarObject { ob_base: PyObject { #[cfg(Py_3_12)] ob_refcnt: pyo3_ffi::PyObjectObRefcnt { ob_refcnt: 0 }, #[cfg(not(Py_3_12))] ob_refcnt: 0, ob_type: core::ptr::addr_of_mut!(PyType_Type), }, ob_size: 0, }, tp_name: "orjson.Fragment\0".as_ptr() as *const c_char, tp_basicsize: core::mem::size_of::() as isize, tp_itemsize: 0, tp_dealloc: Some(orjson_fragment_dealloc), tp_init: None, tp_new: Some(orjson_fragment_tp_new), tp_flags: FRAGMENT_TP_FLAGS, // ... tp_bases: null_mut(), tp_cache: null_mut(), tp_del: None, tp_finalize: None, tp_free: None, tp_is_gc: None, tp_mro: null_mut(), tp_subclasses: null_mut(), tp_vectorcall: None, tp_version_tag: 0, tp_weaklist: null_mut(), #[cfg(not(Py_3_9))] tp_print: None, tp_vectorcall_offset: 0, tp_getattr: None, tp_setattr: None, tp_as_async: null_mut(), tp_repr: None, tp_as_number: null_mut(), tp_as_sequence: null_mut(), tp_as_mapping: null_mut(), tp_hash: None, tp_call: None, tp_str: None, tp_getattro: None, tp_setattro: None, tp_as_buffer: null_mut(), tp_doc: core::ptr::null_mut(), tp_traverse: None, tp_clear: None, tp_richcompare: None, tp_weaklistoffset: 0, tp_iter: None, tp_iternext: None, tp_methods: null_mut(), tp_members: null_mut(), tp_getset: null_mut(), tp_base: null_mut(), tp_dict: null_mut(), tp_descr_get: None, tp_descr_set: None, tp_dictoffset: 0, tp_alloc: None, #[cfg(Py_3_12)] tp_watched: 0, }); let ob_ptr = Box::into_raw(ob); PyType_Ready(ob_ptr); ob_ptr } orjson-3.9.15/src/ffi/long.rs000066400000000000000000000046421456615046100160010ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) // longintrepr.h, _longobject, _PyLongValue #[cfg(Py_3_12)] const SIGN_MASK: usize = 3; #[cfg(Py_3_12)] const SIGN_ZERO: usize = 1; #[cfg(Py_3_12)] #[allow(non_upper_case_globals)] const _PyLong_NON_SIZE_BITS: usize = 3; #[cfg(Py_3_12)] #[repr(C)] struct _PyLongValue { pub lv_tag: usize, pub ob_digit: u32, } #[cfg(Py_3_12)] #[repr(C)] struct PyLongObject { pub ob_refcnt: pyo3_ffi::Py_ssize_t, pub ob_type: *mut pyo3_ffi::PyTypeObject, pub long_value: _PyLongValue, } #[cfg(Py_3_12)] #[inline(always)] pub fn pylong_is_zero(ptr: *mut pyo3_ffi::PyObject) -> bool { unsafe { (*(ptr as *mut PyLongObject)).long_value.lv_tag & SIGN_MASK == SIGN_ZERO } } #[cfg(not(Py_3_12))] #[inline(always)] pub fn pylong_is_zero(ptr: *mut pyo3_ffi::PyObject) -> bool { unsafe { (*(ptr as *mut pyo3_ffi::PyVarObject)).ob_size == 0 } } #[cfg(Py_3_12)] #[inline(always)] pub fn pylong_is_unsigned(ptr: *mut pyo3_ffi::PyObject) -> bool { unsafe { 1 - (((*(ptr as *mut PyLongObject)).long_value.lv_tag & _PyLong_NON_SIZE_BITS) as isize) > 0 } } #[cfg(not(Py_3_12))] #[inline(always)] pub fn pylong_is_unsigned(ptr: *mut pyo3_ffi::PyObject) -> bool { unsafe { (*(ptr as *mut pyo3_ffi::PyVarObject)).ob_size > 0 } } #[cfg(Py_3_12)] #[inline(always)] fn pylong_is_compact(ptr: *mut pyo3_ffi::PyObject) -> bool { unsafe { (*(ptr as *mut PyLongObject)).long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS) } } #[cfg(Py_3_12)] #[inline(always)] pub fn pylong_value_unsigned(ptr: *mut pyo3_ffi::PyObject) -> u64 { if pylong_is_compact(ptr) == true { unsafe { (*(ptr as *mut PyLongObject)).long_value.ob_digit as u64 } } else { ffi!(PyLong_AsUnsignedLongLong(ptr)) } } #[cfg(not(Py_3_12))] #[inline(always)] pub fn pylong_value_unsigned(ptr: *mut pyo3_ffi::PyObject) -> u64 { ffi!(PyLong_AsUnsignedLongLong(ptr)) } #[cfg(not(Py_3_12))] #[inline(always)] pub fn pylong_value_signed(ptr: *mut pyo3_ffi::PyObject) -> i64 { ffi!(PyLong_AsLongLong(ptr)) } #[cfg(Py_3_12)] #[inline(always)] pub fn pylong_value_signed(ptr: *mut pyo3_ffi::PyObject) -> i64 { if pylong_is_compact(ptr) == true { unsafe { let sign = 1 - ((*(ptr as *mut PyLongObject)).long_value.lv_tag & SIGN_MASK) as i64; sign * (*(ptr as *mut PyLongObject)).long_value.ob_digit as i64 } } else { ffi!(PyLong_AsLongLong(ptr)) } } orjson-3.9.15/src/ffi/mod.rs000066400000000000000000000005101456615046100156070ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) mod buffer; mod bytes; mod fragment; mod long; #[cfg(feature = "yyjson")] pub mod yyjson; pub use buffer::*; pub use bytes::*; pub use fragment::{orjson_fragmenttype_new, Fragment}; pub use long::{pylong_is_unsigned, pylong_is_zero, pylong_value_signed, pylong_value_unsigned}; orjson-3.9.15/src/ffi/yyjson.rs000066400000000000000000000034651456615046100163770ustar00rootroot00000000000000#[repr(C)] pub struct yyjson_alc { pub malloc: ::core::option::Option< unsafe extern "C" fn( ctx: *mut ::core::ffi::c_void, size: usize, ) -> *mut ::core::ffi::c_void, >, pub realloc: ::core::option::Option< unsafe extern "C" fn( ctx: *mut ::core::ffi::c_void, ptr: *mut ::core::ffi::c_void, size: usize, ) -> *mut ::core::ffi::c_void, >, pub free: ::core::option::Option< unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, ptr: *mut ::core::ffi::c_void), >, pub ctx: *mut ::core::ffi::c_void, } extern "C" { pub fn yyjson_alc_pool_init( alc: *mut yyjson_alc, buf: *mut ::core::ffi::c_void, size: usize, ) -> bool; } pub type yyjson_read_flag = u32; pub const YYJSON_READ_NOFLAG: yyjson_read_flag = 0; pub type yyjson_read_code = u32; pub const YYJSON_READ_SUCCESS: yyjson_read_code = 0; #[repr(C)] pub struct yyjson_read_err { pub code: yyjson_read_code, pub msg: *const ::core::ffi::c_char, pub pos: usize, } extern "C" { pub fn yyjson_read_opts( dat: *mut ::core::ffi::c_char, len: usize, flg: yyjson_read_flag, alc: *const yyjson_alc, err: *mut yyjson_read_err, ) -> *mut yyjson_doc; } extern "C" { pub fn yyjson_doc_free(doc: *mut yyjson_doc); } #[repr(C)] pub union yyjson_val_uni { pub u64_: u64, pub i64_: i64, pub f64_: f64, pub str_: *const ::core::ffi::c_char, pub ptr: *mut ::core::ffi::c_void, pub ofs: usize, } #[repr(C)] pub struct yyjson_val { pub tag: u64, pub uni: yyjson_val_uni, } #[repr(C)] pub struct yyjson_doc { pub root: *mut yyjson_val, pub alc: yyjson_alc, pub dat_read: usize, pub val_read: usize, pub str_pool: *mut ::core::ffi::c_char, } orjson-3.9.15/src/lib.rs000066400000000000000000000273021456615046100150420ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) #![cfg_attr(feature = "intrinsics", feature(core_intrinsics))] #![cfg_attr(feature = "optimize", feature(optimize_attribute))] #![cfg_attr(feature = "strict_provenance", feature(strict_provenance))] #![cfg_attr(feature = "strict_provenance", warn(fuzzy_provenance_casts))] #![cfg_attr(feature = "unstable-simd", feature(portable_simd))] #![allow(unknown_lints)] // internal_features #![allow(internal_features)] // core_intrinsics #![allow(unused_unsafe)] #![allow(non_camel_case_types)] #![allow(clippy::missing_safety_doc)] #![allow(clippy::redundant_field_names)] #![allow(clippy::uninlined_format_args)] // MSRV 1.66 #![allow(clippy::upper_case_acronyms)] #![allow(clippy::zero_prefixed_literal)] #[macro_use] mod util; mod deserialize; mod ffi; mod opt; mod serialize; mod str; mod typeref; use core::ffi::{c_char, c_int, c_void}; use pyo3_ffi::*; #[allow(unused_imports)] use core::ptr::{null, null_mut, NonNull}; #[cfg(Py_3_10)] macro_rules! add { ($mptr:expr, $name:expr, $obj:expr) => { PyModule_AddObjectRef($mptr, $name.as_ptr() as *const c_char, $obj); }; } #[cfg(not(Py_3_10))] macro_rules! add { ($mptr:expr, $name:expr, $obj:expr) => { PyModule_AddObject($mptr, $name.as_ptr() as *const c_char, $obj); }; } macro_rules! opt { ($mptr:expr, $name:expr, $opt:expr) => { #[cfg(all(not(target_os = "windows"), target_pointer_width = "64"))] PyModule_AddIntConstant($mptr, $name.as_ptr() as *const c_char, $opt as i64); #[cfg(all(not(target_os = "windows"), target_pointer_width = "32"))] PyModule_AddIntConstant($mptr, $name.as_ptr() as *const c_char, $opt as i32); #[cfg(target_os = "windows")] PyModule_AddIntConstant($mptr, $name.as_ptr() as *const c_char, $opt as i32); }; } #[allow(non_snake_case)] #[no_mangle] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub unsafe extern "C" fn orjson_init_exec(mptr: *mut PyObject) -> c_int { typeref::init_typerefs(); { let version = env!("CARGO_PKG_VERSION"); let pyversion = PyUnicode_FromStringAndSize(version.as_ptr() as *const c_char, version.len() as isize); add!(mptr, "__version__\0", pyversion); } { let dumps_doc = "dumps(obj, /, default=None, option=None)\n--\n\nSerialize Python objects to JSON.\0"; let wrapped_dumps = PyMethodDef { ml_name: "dumps\0".as_ptr() as *const c_char, ml_meth: PyMethodDefPointer { _PyCFunctionFastWithKeywords: dumps, }, ml_flags: pyo3_ffi::METH_FASTCALL | METH_KEYWORDS, ml_doc: dumps_doc.as_ptr() as *const c_char, }; let func = PyCFunction_NewEx( Box::into_raw(Box::new(wrapped_dumps)), null_mut(), PyUnicode_InternFromString("orjson\0".as_ptr() as *const c_char), ); add!(mptr, "dumps\0", func); } { let loads_doc = "loads(obj, /)\n--\n\nDeserialize JSON to Python objects.\0"; let wrapped_loads = PyMethodDef { ml_name: "loads\0".as_ptr() as *const c_char, ml_meth: PyMethodDefPointer { PyCFunction: loads }, ml_flags: METH_O, ml_doc: loads_doc.as_ptr() as *const c_char, }; let func = PyCFunction_NewEx( Box::into_raw(Box::new(wrapped_loads)), null_mut(), PyUnicode_InternFromString("orjson\0".as_ptr() as *const c_char), ); add!(mptr, "loads\0", func); } add!(mptr, "Fragment\0", typeref::FRAGMENT_TYPE as *mut PyObject); opt!(mptr, "OPT_APPEND_NEWLINE\0", opt::APPEND_NEWLINE); opt!(mptr, "OPT_INDENT_2\0", opt::INDENT_2); opt!(mptr, "OPT_NAIVE_UTC\0", opt::NAIVE_UTC); opt!(mptr, "OPT_NON_STR_KEYS\0", opt::NON_STR_KEYS); opt!(mptr, "OPT_OMIT_MICROSECONDS\0", opt::OMIT_MICROSECONDS); opt!( mptr, "OPT_PASSTHROUGH_DATACLASS\0", opt::PASSTHROUGH_DATACLASS ); opt!( mptr, "OPT_PASSTHROUGH_DATETIME\0", opt::PASSTHROUGH_DATETIME ); opt!( mptr, "OPT_PASSTHROUGH_SUBCLASS\0", opt::PASSTHROUGH_SUBCLASS ); opt!(mptr, "OPT_SERIALIZE_DATACLASS\0", opt::SERIALIZE_DATACLASS); opt!(mptr, "OPT_SERIALIZE_NUMPY\0", opt::SERIALIZE_NUMPY); opt!(mptr, "OPT_SERIALIZE_UUID\0", opt::SERIALIZE_UUID); opt!(mptr, "OPT_SORT_KEYS\0", opt::SORT_KEYS); opt!(mptr, "OPT_STRICT_INTEGER\0", opt::STRICT_INTEGER); opt!(mptr, "OPT_UTC_Z\0", opt::UTC_Z); add!(mptr, "JSONDecodeError\0", typeref::JsonDecodeError); add!(mptr, "JSONEncodeError\0", typeref::JsonEncodeError); 0 } #[cfg(not(Py_3_12))] const PYMODULEDEF_LEN: usize = 2; #[cfg(Py_3_12)] const PYMODULEDEF_LEN: usize = 3; #[allow(non_snake_case)] #[no_mangle] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub unsafe extern "C" fn PyInit_orjson() -> *mut PyModuleDef { let mod_slots: Box<[PyModuleDef_Slot; PYMODULEDEF_LEN]> = Box::new([ PyModuleDef_Slot { slot: Py_mod_exec, value: orjson_init_exec as *mut c_void, }, #[cfg(Py_3_12)] PyModuleDef_Slot { slot: Py_mod_multiple_interpreters, value: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED, }, PyModuleDef_Slot { slot: 0, value: null_mut(), }, ]); let init = Box::new(PyModuleDef { m_base: PyModuleDef_HEAD_INIT, m_name: "orjson\0".as_ptr() as *const c_char, m_doc: null(), m_size: 0, m_methods: null_mut(), m_slots: Box::into_raw(mod_slots) as *mut PyModuleDef_Slot, m_traverse: None, m_clear: None, m_free: None, }); let init_ptr = Box::into_raw(init); PyModuleDef_Init(init_ptr); init_ptr } #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn raise_loads_exception(err: deserialize::DeserializeError) -> *mut PyObject { let pos = err.pos(); let msg = err.message; let doc = match err.data { Some(as_str) => unsafe { PyUnicode_FromStringAndSize(as_str.as_ptr() as *const c_char, as_str.len() as isize) }, None => { use_immortal!(crate::typeref::EMPTY_UNICODE) } }; unsafe { let err_msg = PyUnicode_FromStringAndSize(msg.as_ptr() as *const c_char, msg.len() as isize); let args = PyTuple_New(3); let pos = PyLong_FromLongLong(pos); PyTuple_SET_ITEM(args, 0, err_msg); PyTuple_SET_ITEM(args, 1, doc); PyTuple_SET_ITEM(args, 2, pos); PyErr_SetObject(typeref::JsonDecodeError, args); debug_assert!(ffi!(Py_REFCNT(args)) <= 2); Py_DECREF(args); }; null_mut() } #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn raise_dumps_exception_fixed(msg: &str) -> *mut PyObject { unsafe { let err_msg = PyUnicode_FromStringAndSize(msg.as_ptr() as *const c_char, msg.len() as isize); PyErr_SetObject(typeref::JsonEncodeError, err_msg); debug_assert!(ffi!(Py_REFCNT(err_msg)) <= 2); Py_DECREF(err_msg); }; null_mut() } #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] #[cfg(Py_3_12)] fn raise_dumps_exception_dynamic(err: &str) -> *mut PyObject { unsafe { let cause_exc: *mut PyObject = PyErr_GetRaisedException(); let err_msg = PyUnicode_FromStringAndSize(err.as_ptr() as *const c_char, err.len() as isize); PyErr_SetObject(typeref::JsonEncodeError, err_msg); debug_assert!(ffi!(Py_REFCNT(err_msg)) <= 2); Py_DECREF(err_msg); if !cause_exc.is_null() { let exc: *mut PyObject = PyErr_GetRaisedException(); PyException_SetCause(exc, cause_exc); PyErr_SetRaisedException(exc); } }; null_mut() } #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] #[cfg(not(Py_3_12))] fn raise_dumps_exception_dynamic(err: &str) -> *mut PyObject { unsafe { let mut cause_tp: *mut PyObject = null_mut(); let mut cause_val: *mut PyObject = null_mut(); let mut cause_traceback: *mut PyObject = null_mut(); PyErr_Fetch(&mut cause_tp, &mut cause_val, &mut cause_traceback); let err_msg = PyUnicode_FromStringAndSize(err.as_ptr() as *const c_char, err.len() as isize); PyErr_SetObject(typeref::JsonEncodeError, err_msg); debug_assert!(ffi!(Py_REFCNT(err_msg)) == 2); Py_DECREF(err_msg); let mut tp: *mut PyObject = null_mut(); let mut val: *mut PyObject = null_mut(); let mut traceback: *mut PyObject = null_mut(); PyErr_Fetch(&mut tp, &mut val, &mut traceback); PyErr_NormalizeException(&mut tp, &mut val, &mut traceback); if !cause_tp.is_null() { PyErr_NormalizeException(&mut cause_tp, &mut cause_val, &mut cause_traceback); PyException_SetCause(val, cause_val); Py_DECREF(cause_tp); } if !cause_traceback.is_null() { Py_DECREF(cause_traceback); } PyErr_Restore(tp, val, traceback); }; null_mut() } #[no_mangle] pub unsafe extern "C" fn loads(_self: *mut PyObject, obj: *mut PyObject) -> *mut PyObject { match crate::deserialize::deserialize(obj) { Ok(val) => val.as_ptr(), Err(err) => raise_loads_exception(err), } } #[no_mangle] pub unsafe extern "C" fn dumps( _self: *mut PyObject, args: *const *mut PyObject, nargs: Py_ssize_t, kwnames: *mut PyObject, ) -> *mut PyObject { let mut default: Option> = None; let mut optsptr: Option> = None; let num_args = PyVectorcall_NARGS(nargs as usize); if unlikely!(num_args == 0) { return raise_dumps_exception_fixed( "dumps() missing 1 required positional argument: 'obj'", ); } if num_args & 2 == 2 { default = Some(NonNull::new_unchecked(*args.offset(1))); } if num_args & 3 == 3 { optsptr = Some(NonNull::new_unchecked(*args.offset(2))); } if !kwnames.is_null() { for i in 0..=Py_SIZE(kwnames).saturating_sub(1) { let arg = PyTuple_GET_ITEM(kwnames, i as Py_ssize_t); if arg == typeref::DEFAULT { if unlikely!(num_args & 2 == 2) { return raise_dumps_exception_fixed( "dumps() got multiple values for argument: 'default'", ); } default = Some(NonNull::new_unchecked(*args.offset(num_args + i))); } else if arg == typeref::OPTION { if unlikely!(num_args & 3 == 3) { return raise_dumps_exception_fixed( "dumps() got multiple values for argument: 'option'", ); } optsptr = Some(NonNull::new_unchecked(*args.offset(num_args + i))); } else { return raise_dumps_exception_fixed("dumps() got an unexpected keyword argument"); } } } let mut optsbits: i32 = 0; if let Some(opts) = optsptr { if opts.as_ptr() == typeref::NONE { } else if (*opts.as_ptr()).ob_type != typeref::INT_TYPE { return raise_dumps_exception_fixed("Invalid opts"); } else { optsbits = PyLong_AsLong(optsptr.unwrap().as_ptr()) as i32; if !(0..=opt::MAX_OPT).contains(&optsbits) { return raise_dumps_exception_fixed("Invalid opts"); } } } match crate::serialize::serialize(*args, default, optsbits as opt::Opt) { Ok(val) => val.as_ptr(), Err(err) => raise_dumps_exception_dynamic(err.as_str()), } } orjson-3.9.15/src/opt.rs000066400000000000000000000021551456615046100150750ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) pub type Opt = u32; pub const INDENT_2: Opt = 1; pub const NAIVE_UTC: Opt = 1 << 1; pub const NON_STR_KEYS: Opt = 1 << 2; pub const OMIT_MICROSECONDS: Opt = 1 << 3; pub const SERIALIZE_NUMPY: Opt = 1 << 4; pub const SORT_KEYS: Opt = 1 << 5; pub const STRICT_INTEGER: Opt = 1 << 6; pub const UTC_Z: Opt = 1 << 7; pub const PASSTHROUGH_SUBCLASS: Opt = 1 << 8; pub const PASSTHROUGH_DATETIME: Opt = 1 << 9; pub const APPEND_NEWLINE: Opt = 1 << 10; pub const PASSTHROUGH_DATACLASS: Opt = 1 << 11; // deprecated pub const SERIALIZE_DATACLASS: Opt = 0; pub const SERIALIZE_UUID: Opt = 0; pub const SORT_OR_NON_STR_KEYS: Opt = SORT_KEYS | NON_STR_KEYS; pub const NOT_PASSTHROUGH: Opt = !(PASSTHROUGH_DATETIME | PASSTHROUGH_DATACLASS | PASSTHROUGH_SUBCLASS); pub const MAX_OPT: i32 = (APPEND_NEWLINE | INDENT_2 | NAIVE_UTC | NON_STR_KEYS | OMIT_MICROSECONDS | PASSTHROUGH_DATETIME | PASSTHROUGH_DATACLASS | PASSTHROUGH_SUBCLASS | SERIALIZE_DATACLASS | SERIALIZE_NUMPY | SERIALIZE_UUID | SORT_KEYS | STRICT_INTEGER | UTC_Z) as i32; orjson-3.9.15/src/serialize/000077500000000000000000000000001456615046100157115ustar00rootroot00000000000000orjson-3.9.15/src/serialize/error.rs000066400000000000000000000050411456615046100174100ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::CStr; use core::ptr::NonNull; pub enum SerializeError { DatetimeLibraryUnsupported, DefaultRecursionLimit, Integer53Bits, Integer64Bits, InvalidStr, InvalidFragment, KeyMustBeStr, RecursionLimit, TimeHasTzinfo, DictIntegerKey64Bit, DictKeyInvalidType, NumpyMalformed, NumpyNotCContiguous, NumpyUnsupportedDatatype, UnsupportedType(NonNull), } impl std::fmt::Display for SerializeError { #[cold] #[cfg_attr(feature = "optimize", optimize(size))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match *self { SerializeError::DatetimeLibraryUnsupported => write!(f, "datetime's timezone library is not supported: use datetime.timezone.utc, pendulum, pytz, or dateutil"), SerializeError::DefaultRecursionLimit => { write!(f, "default serializer exceeds recursion limit") } SerializeError::Integer53Bits => write!(f, "Integer exceeds 53-bit range"), SerializeError::Integer64Bits => write!(f, "Integer exceeds 64-bit range"), SerializeError::InvalidStr => write!(f, "{}", crate::util::INVALID_STR), SerializeError::InvalidFragment => write!(f, "orjson.Fragment's content is not of type bytes or str"), SerializeError::KeyMustBeStr => write!(f, "Dict key must be str"), SerializeError::RecursionLimit => write!(f, "Recursion limit reached"), SerializeError::TimeHasTzinfo => write!(f, "datetime.time must not have tzinfo set"), SerializeError::DictIntegerKey64Bit => { write!(f, "Dict integer key must be within 64-bit range") } SerializeError::DictKeyInvalidType => { write!(f, "Dict key must a type serializable with OPT_NON_STR_KEYS") } SerializeError::NumpyMalformed => write!(f, "numpy array is malformed"), SerializeError::NumpyNotCContiguous => write!( f, "numpy array is not C contiguous; use ndarray.tolist() in default" ), SerializeError::NumpyUnsupportedDatatype => { write!(f, "unsupported datatype in numpy array") } SerializeError::UnsupportedType(ptr) => { let name = unsafe { CStr::from_ptr((*ob_type!(ptr.as_ptr())).tp_name).to_string_lossy() }; write!(f, "Type is not JSON serializable: {}", name) } } } } orjson-3.9.15/src/serialize/mod.rs000066400000000000000000000002351456615046100170360ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) mod error; mod obtype; mod per_type; mod serializer; mod state; mod writer; pub use serializer::serialize; orjson-3.9.15/src/serialize/obtype.rs000066400000000000000000000062021456615046100175610ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::{ Opt, PASSTHROUGH_DATACLASS, PASSTHROUGH_DATETIME, PASSTHROUGH_SUBCLASS, SERIALIZE_NUMPY, }; use crate::serialize::per_type::{is_numpy_array, is_numpy_scalar}; use crate::typeref::{ BOOL_TYPE, DATACLASS_FIELDS_STR, DATETIME_TYPE, DATE_TYPE, DICT_TYPE, ENUM_TYPE, FLOAT_TYPE, FRAGMENT_TYPE, INT_TYPE, LIST_TYPE, NONE_TYPE, STR_TYPE, TIME_TYPE, TUPLE_TYPE, UUID_TYPE, }; #[repr(u32)] pub enum ObType { Str, Int, Bool, None, Float, List, Dict, Datetime, Date, Time, Tuple, Uuid, Dataclass, NumpyScalar, NumpyArray, Enum, StrSubclass, Fragment, Unknown, } pub fn pyobject_to_obtype(obj: *mut pyo3_ffi::PyObject, opts: Opt) -> ObType { let ob_type = ob_type!(obj); if is_class_by_type!(ob_type, STR_TYPE) { ObType::Str } else if is_class_by_type!(ob_type, INT_TYPE) { ObType::Int } else if is_class_by_type!(ob_type, BOOL_TYPE) { ObType::Bool } else if is_class_by_type!(ob_type, NONE_TYPE) { ObType::None } else if is_class_by_type!(ob_type, FLOAT_TYPE) { ObType::Float } else if is_class_by_type!(ob_type, LIST_TYPE) { ObType::List } else if is_class_by_type!(ob_type, DICT_TYPE) { ObType::Dict } else if is_class_by_type!(ob_type, DATETIME_TYPE) && opt_disabled!(opts, PASSTHROUGH_DATETIME) { ObType::Datetime } else { pyobject_to_obtype_unlikely(ob_type, opts) } } #[cfg_attr(feature = "optimize", optimize(size))] #[inline(never)] pub fn pyobject_to_obtype_unlikely(ob_type: *mut pyo3_ffi::PyTypeObject, opts: Opt) -> ObType { if is_class_by_type!(ob_type, UUID_TYPE) { return ObType::Uuid; } else if is_class_by_type!(ob_type, TUPLE_TYPE) { return ObType::Tuple; } else if is_class_by_type!(ob_type, FRAGMENT_TYPE) { return ObType::Fragment; } if opt_disabled!(opts, PASSTHROUGH_DATETIME) { if is_class_by_type!(ob_type, DATE_TYPE) { return ObType::Date; } else if is_class_by_type!(ob_type, TIME_TYPE) { return ObType::Time; } } if opt_disabled!(opts, PASSTHROUGH_SUBCLASS) { if is_subclass_by_flag!(ob_type, Py_TPFLAGS_UNICODE_SUBCLASS) { return ObType::StrSubclass; } else if is_subclass_by_flag!(ob_type, Py_TPFLAGS_LONG_SUBCLASS) { return ObType::Int; } else if is_subclass_by_flag!(ob_type, Py_TPFLAGS_LIST_SUBCLASS) { return ObType::List; } else if is_subclass_by_flag!(ob_type, Py_TPFLAGS_DICT_SUBCLASS) { return ObType::Dict; } } if is_subclass_by_type!(ob_type, ENUM_TYPE) { return ObType::Enum; } if opt_disabled!(opts, PASSTHROUGH_DATACLASS) && pydict_contains!(ob_type, DATACLASS_FIELDS_STR) { return ObType::Dataclass; } if unlikely!(opt_enabled!(opts, SERIALIZE_NUMPY)) { if is_numpy_scalar(ob_type) { return ObType::NumpyScalar; } else if is_numpy_array(ob_type) { return ObType::NumpyArray; } } ObType::Unknown } orjson-3.9.15/src/serialize/per_type/000077500000000000000000000000001456615046100175405ustar00rootroot00000000000000orjson-3.9.15/src/serialize/per_type/dataclass.rs000066400000000000000000000144701456615046100220530ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::serialize::error::SerializeError; use crate::serialize::per_type::dict::ZeroDictSerializer; use crate::serialize::serializer::PyObjectSerializer; use crate::serialize::state::SerializerState; use crate::str::unicode_to_str; use crate::typeref::{ DATACLASS_FIELDS_STR, DICT_STR, FIELD_TYPE, FIELD_TYPE_STR, SLOTS_STR, STR_TYPE, }; use serde::ser::{Serialize, SerializeMap, Serializer}; use core::ptr::NonNull; #[repr(transparent)] pub struct DataclassGenericSerializer<'a> { previous: &'a PyObjectSerializer, } impl<'a> DataclassGenericSerializer<'a> { pub fn new(previous: &'a PyObjectSerializer) -> Self { Self { previous: previous } } } impl<'a> Serialize for DataclassGenericSerializer<'a> { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { if unlikely!(self.previous.state.recursion_limit()) { err!(SerializeError::RecursionLimit) } let dict = ffi!(PyObject_GetAttr(self.previous.ptr, DICT_STR)); let ob_type = ob_type!(self.previous.ptr); if unlikely!(dict.is_null()) { ffi!(PyErr_Clear()); DataclassFallbackSerializer::new( self.previous.ptr, self.previous.state, self.previous.default, ) .serialize(serializer) } else if pydict_contains!(ob_type, SLOTS_STR) { let ret = DataclassFallbackSerializer::new( self.previous.ptr, self.previous.state, self.previous.default, ) .serialize(serializer); ffi!(Py_DECREF(dict)); ret } else { let ret = DataclassFastSerializer::new(dict, self.previous.state, self.previous.default) .serialize(serializer); ffi!(Py_DECREF(dict)); ret } } } pub struct DataclassFastSerializer { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl DataclassFastSerializer { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { DataclassFastSerializer { ptr: ptr, state: state.copy_for_recursive_call(), default: default, } } } impl Serialize for DataclassFastSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { let len = ffi!(Py_SIZE(self.ptr)) as usize; if unlikely!(len == 0) { return ZeroDictSerializer::new().serialize(serializer); } let mut map = serializer.serialize_map(None).unwrap(); let mut next_key: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut next_value: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut pos = 0; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); for _ in 0..=ffi!(Py_SIZE(self.ptr)) as usize - 1 { let key = next_key; let value = next_value; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); if unlikely!(unsafe { ob_type!(key) != STR_TYPE }) { err!(SerializeError::KeyMustBeStr) } let data = unicode_to_str(key); if unlikely!(data.is_none()) { err!(SerializeError::InvalidStr) } let key_as_str = data.unwrap(); if unlikely!(key_as_str.as_bytes()[0] == b'_') { continue; } let pyvalue = PyObjectSerializer::new(value, self.state, self.default); map.serialize_key(key_as_str).unwrap(); map.serialize_value(&pyvalue)?; } map.end() } } pub struct DataclassFallbackSerializer { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl DataclassFallbackSerializer { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { DataclassFallbackSerializer { ptr: ptr, state: state.copy_for_recursive_call(), default: default, } } } impl Serialize for DataclassFallbackSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { let fields = ffi!(PyObject_GetAttr(self.ptr, DATACLASS_FIELDS_STR)); debug_assert!(ffi!(Py_REFCNT(fields)) >= 2); ffi!(Py_DECREF(fields)); let len = ffi!(Py_SIZE(fields)) as usize; if unlikely!(len == 0) { return ZeroDictSerializer::new().serialize(serializer); } let mut map = serializer.serialize_map(None).unwrap(); let mut next_key: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut next_value: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut pos = 0; pydict_next!(fields, &mut pos, &mut next_key, &mut next_value); for _ in 0..=ffi!(Py_SIZE(fields)) as usize - 1 { let attr = next_key; let field = next_value; pydict_next!(fields, &mut pos, &mut next_key, &mut next_value); let field_type = ffi!(PyObject_GetAttr(field, FIELD_TYPE_STR)); debug_assert!(ffi!(Py_REFCNT(field_type)) >= 2); ffi!(Py_DECREF(field_type)); if unsafe { field_type as *mut pyo3_ffi::PyTypeObject != FIELD_TYPE } { continue; } let data = unicode_to_str(attr); if unlikely!(data.is_none()) { err!(SerializeError::InvalidStr); } let key_as_str = data.unwrap(); if key_as_str.as_bytes()[0] == b'_' { continue; } let value = ffi!(PyObject_GetAttr(self.ptr, attr)); debug_assert!(ffi!(Py_REFCNT(value)) >= 2); ffi!(Py_DECREF(value)); let pyvalue = PyObjectSerializer::new(value, self.state, self.default); map.serialize_key(key_as_str).unwrap(); map.serialize_value(&pyvalue)? } map.end() } } orjson-3.9.15/src/serialize/per_type/datetime.rs000066400000000000000000000173731456615046100217150ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::*; use crate::serialize::error::SerializeError; use crate::serialize::per_type::datetimelike::{ DateTimeBuffer, DateTimeError, DateTimeLike, Offset, }; #[cfg(Py_3_9)] use crate::typeref::ZONEINFO_TYPE; use crate::typeref::{CONVERT_METHOD_STR, DST_STR, NORMALIZE_METHOD_STR, UTCOFFSET_METHOD_STR}; use serde::ser::{Serialize, Serializer}; macro_rules! write_double_digit { ($buf:ident, $value:ident) => { if $value < 10 { $buf.push(b'0'); } $buf.extend_from_slice(itoa::Buffer::new().format($value).as_bytes()); }; } macro_rules! write_microsecond { ($buf:ident, $microsecond:ident) => { if $microsecond != 0 { let mut buf = itoa::Buffer::new(); let formatted = buf.format($microsecond); $buf.extend_from_slice( &[b'.', b'0', b'0', b'0', b'0', b'0', b'0'][..(7 - formatted.len())], ); $buf.extend_from_slice(formatted.as_bytes()); } }; } #[repr(transparent)] pub struct Date { ptr: *mut pyo3_ffi::PyObject, } impl Date { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { Date { ptr: ptr } } pub fn write_buf(&self, buf: &mut DateTimeBuffer) { { let year = ffi!(PyDateTime_GET_YEAR(self.ptr)); let mut yearbuf = itoa::Buffer::new(); let formatted = yearbuf.format(year); if unlikely!(year < 1000) { // date-fullyear = 4DIGIT buf.extend_from_slice(&[b'0', b'0', b'0', b'0'][..(4 - formatted.len())]); } buf.extend_from_slice(formatted.as_bytes()); } buf.push(b'-'); { let month = ffi!(PyDateTime_GET_MONTH(self.ptr)) as u32; write_double_digit!(buf, month); } buf.push(b'-'); { let day = ffi!(PyDateTime_GET_DAY(self.ptr)) as u32; write_double_digit!(buf, day); } } } impl Serialize for Date { #[cold] #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut buf = DateTimeBuffer::new(); self.write_buf(&mut buf); serializer.serialize_str(str_from_slice!(buf.as_ptr(), buf.len())) } } pub enum TimeError { HasTimezone, } pub struct Time { ptr: *mut pyo3_ffi::PyObject, opts: Opt, } impl Time { pub fn new(ptr: *mut pyo3_ffi::PyObject, opts: Opt) -> Self { Time { ptr: ptr, opts: opts, } } pub fn write_buf(&self, buf: &mut DateTimeBuffer) -> Result<(), TimeError> { if unsafe { (*(self.ptr as *mut pyo3_ffi::PyDateTime_Time)).hastzinfo == 1 } { return Err(TimeError::HasTimezone); } let hour = ffi!(PyDateTime_TIME_GET_HOUR(self.ptr)) as u8; write_double_digit!(buf, hour); buf.push(b':'); let minute = ffi!(PyDateTime_TIME_GET_MINUTE(self.ptr)) as u8; write_double_digit!(buf, minute); buf.push(b':'); let second = ffi!(PyDateTime_TIME_GET_SECOND(self.ptr)) as u8; write_double_digit!(buf, second); if opt_disabled!(self.opts, OMIT_MICROSECONDS) { let microsecond = ffi!(PyDateTime_TIME_GET_MICROSECOND(self.ptr)) as u32; write_microsecond!(buf, microsecond); } Ok(()) } } impl Serialize for Time { #[cold] #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut buf = DateTimeBuffer::new(); if self.write_buf(&mut buf).is_err() { err!(SerializeError::DatetimeLibraryUnsupported) }; serializer.serialize_str(str_from_slice!(buf.as_ptr(), buf.len())) } } pub struct DateTime { ptr: *mut pyo3_ffi::PyObject, opts: Opt, } impl DateTime { pub fn new(ptr: *mut pyo3_ffi::PyObject, opts: Opt) -> Self { DateTime { ptr: ptr, opts: opts, } } } macro_rules! pydatetime_get { ($fn: ident, $pyfn: ident, $ty: ident) => { fn $fn(&self) -> $ty { ffi!($pyfn(self.ptr)) as $ty } }; } impl DateTimeLike for DateTime { pydatetime_get!(year, PyDateTime_GET_YEAR, i32); pydatetime_get!(month, PyDateTime_GET_MONTH, u8); pydatetime_get!(day, PyDateTime_GET_DAY, u8); pydatetime_get!(hour, PyDateTime_DATE_GET_HOUR, u8); pydatetime_get!(minute, PyDateTime_DATE_GET_MINUTE, u8); pydatetime_get!(second, PyDateTime_DATE_GET_SECOND, u8); pydatetime_get!(microsecond, PyDateTime_DATE_GET_MICROSECOND, u32); fn nanosecond(&self) -> u32 { self.microsecond() * 1_000 } fn has_tz(&self) -> bool { unsafe { (*(self.ptr as *mut pyo3_ffi::PyDateTime_DateTime)).hastzinfo == 1 } } fn slow_offset(&self) -> Result { let tzinfo = ffi!(PyDateTime_DATE_GET_TZINFO(self.ptr)); if ffi!(PyObject_HasAttr(tzinfo, CONVERT_METHOD_STR)) == 1 { // pendulum let py_offset = call_method!(self.ptr, UTCOFFSET_METHOD_STR); let offset = Offset { second: ffi!(PyDateTime_DELTA_GET_SECONDS(py_offset)), day: ffi!(PyDateTime_DELTA_GET_DAYS(py_offset)), }; ffi!(Py_DECREF(py_offset)); Ok(offset) } else if ffi!(PyObject_HasAttr(tzinfo, NORMALIZE_METHOD_STR)) == 1 { // pytz let method_ptr = call_method!(tzinfo, NORMALIZE_METHOD_STR, self.ptr); let py_offset = call_method!(method_ptr, UTCOFFSET_METHOD_STR); ffi!(Py_DECREF(method_ptr)); let offset = Offset { second: ffi!(PyDateTime_DELTA_GET_SECONDS(py_offset)), day: ffi!(PyDateTime_DELTA_GET_DAYS(py_offset)), }; ffi!(Py_DECREF(py_offset)); Ok(offset) } else if ffi!(PyObject_HasAttr(tzinfo, DST_STR)) == 1 { // dateutil/arrow, datetime.timezone.utc let py_offset = call_method!(tzinfo, UTCOFFSET_METHOD_STR, self.ptr); let offset = Offset { second: ffi!(PyDateTime_DELTA_GET_SECONDS(py_offset)), day: ffi!(PyDateTime_DELTA_GET_DAYS(py_offset)), }; ffi!(Py_DECREF(py_offset)); Ok(offset) } else { Err(DateTimeError::LibraryUnsupported) } } #[cfg(Py_3_9)] fn offset(&self) -> Result { if !self.has_tz() { Ok(Offset::default()) } else { let tzinfo = ffi!(PyDateTime_DATE_GET_TZINFO(self.ptr)); if unsafe { ob_type!(tzinfo) == ZONEINFO_TYPE } { // zoneinfo let py_offset = call_method!(tzinfo, UTCOFFSET_METHOD_STR, self.ptr); let offset = Offset { second: ffi!(PyDateTime_DELTA_GET_SECONDS(py_offset)), day: ffi!(PyDateTime_DELTA_GET_DAYS(py_offset)), }; ffi!(Py_DECREF(py_offset)); Ok(offset) } else { self.slow_offset() } } } #[cfg(not(Py_3_9))] fn offset(&self) -> Result { if !self.has_tz() { Ok(Offset::default()) } else { self.slow_offset() } } } impl Serialize for DateTime { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut buf = DateTimeBuffer::new(); if self.write_buf(&mut buf, self.opts).is_err() { err!(SerializeError::DatetimeLibraryUnsupported) } serializer.serialize_str(str_from_slice!(buf.as_ptr(), buf.len())) } } orjson-3.9.15/src/serialize/per_type/datetimelike.rs000066400000000000000000000135451456615046100225570ustar00rootroot00000000000000use crate::opt::*; pub enum DateTimeError { LibraryUnsupported, } #[repr(transparent)] pub struct DateTimeBuffer { buf: arrayvec::ArrayVec, } impl DateTimeBuffer { pub fn new() -> DateTimeBuffer { DateTimeBuffer { buf: arrayvec::ArrayVec::::new(), } } pub fn push(&mut self, value: u8) { self.buf.push(value); } pub fn extend_from_slice(&mut self, slice: &[u8]) { self.buf.try_extend_from_slice(slice).unwrap(); } pub fn as_ptr(&self) -> *const u8 { self.buf.as_ptr() } pub fn len(&self) -> usize { self.buf.len() } } macro_rules! write_double_digit { ($buf:ident, $value:expr) => { if $value < 10 { $buf.push(b'0'); } $buf.extend_from_slice(itoa::Buffer::new().format($value).as_bytes()); }; } macro_rules! write_triple_digit { ($buf:ident, $value:expr) => { if $value < 100 { $buf.push(b'0'); } if $value < 10 { $buf.push(b'0'); } $buf.extend_from_slice(itoa::Buffer::new().format($value).as_bytes()); }; } #[derive(Default)] pub struct Offset { pub day: i32, pub second: i32, } /// Trait providing a method to write a datetime-like object to a buffer in an RFC3339-compatible format. /// /// The provided `write_buf` method does not allocate, and is faster /// than writing to a heap-allocated string. pub trait DateTimeLike { /// Returns the year component of the datetime. fn year(&self) -> i32; /// Returns the month component of the datetime. fn month(&self) -> u8; /// Returns the day component of the datetime. fn day(&self) -> u8; /// Returns the hour component of the datetime. fn hour(&self) -> u8; /// Returns the minute component of the datetime. fn minute(&self) -> u8; /// Returns the second component of the datetime. fn second(&self) -> u8; /// Returns the number of microseconds since the whole non-leap second. fn microsecond(&self) -> u32; /// Returns the number of nanoseconds since the whole non-leap second. fn nanosecond(&self) -> u32; /// Is the object time-zone aware? fn has_tz(&self) -> bool; //// python3.8 or below implementation of offset() fn slow_offset(&self) -> Result; /// The offset of the timezone. fn offset(&self) -> Result; /// Write `self` to a buffer in RFC3339 format, using `opts` to /// customise if desired. #[cfg_attr(feature = "optimize", optimize(size))] fn write_buf(&self, buf: &mut DateTimeBuffer, opts: Opt) -> Result<(), DateTimeError> { { let year = self.year(); let mut yearbuf = itoa::Buffer::new(); let formatted = yearbuf.format(year); if unlikely!(year < 1000) { // date-fullyear = 4DIGIT buf.extend_from_slice(&[b'0', b'0', b'0', b'0'][..(4 - formatted.len())]); } buf.extend_from_slice(formatted.as_bytes()); } buf.push(b'-'); write_double_digit!(buf, self.month()); buf.push(b'-'); write_double_digit!(buf, self.day()); buf.push(b'T'); write_double_digit!(buf, self.hour()); buf.push(b':'); write_double_digit!(buf, self.minute()); buf.push(b':'); write_double_digit!(buf, self.second()); if opt_disabled!(opts, OMIT_MICROSECONDS) { let microsecond = self.microsecond(); if microsecond != 0 { buf.push(b'.'); write_triple_digit!(buf, microsecond / 1_000); write_triple_digit!(buf, microsecond % 1_000); // Don't support writing nanoseconds for now. // If requested, something like the following should work, // and the `DateTimeBuffer` type alias should be changed to // have length 35. // let nanosecond = self.nanosecond(); // if nanosecond % 1_000 != 0 { // write_triple_digit!(buf, nanosecond % 1_000); // } } } if self.has_tz() || opt_enabled!(opts, NAIVE_UTC) { let offset = self.offset()?; let mut offset_second = offset.second; if offset_second == 0 { if opt_enabled!(opts, UTC_Z) { buf.push(b'Z'); } else { buf.extend_from_slice(&[b'+', b'0', b'0', b':', b'0', b'0']); } } else { // This branch is only really hit by the Python datetime implementation, // since numpy datetimes are all converted to UTC. if offset.day == -1 { // datetime.timedelta(days=-1, seconds=68400) -> -05:00 buf.push(b'-'); offset_second = 86400 - offset_second; } else { // datetime.timedelta(seconds=37800) -> +10:30 buf.push(b'+'); } let offset_minute = offset_second / 60; let offset_hour = offset_minute / 60; write_double_digit!(buf, offset_hour); buf.push(b':'); let mut offset_minute_print = offset_minute % 60; // https://tools.ietf.org/html/rfc3339#section-5.8 // "exactly 19 minutes and 32.13 seconds ahead of UTC" // "closest representable UTC offset" // "+20:00" let offset_excess_second = offset_second - (offset_minute_print * 60 + offset_hour * 3600); if offset_excess_second >= 30 { offset_minute_print += 1; } write_double_digit!(buf, offset_minute_print); } } Ok(()) } } orjson-3.9.15/src/serialize/per_type/default.rs000066400000000000000000000041471456615046100215400ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::serialize::error::SerializeError; use crate::serialize::serializer::PyObjectSerializer; use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct DefaultSerializer<'a> { previous: &'a PyObjectSerializer, } impl<'a> DefaultSerializer<'a> { pub fn new(previous: &'a PyObjectSerializer) -> Self { Self { previous: previous } } } impl<'a> Serialize for DefaultSerializer<'a> { #[cold] #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { match self.previous.default { Some(callable) => { if unlikely!(self.previous.state.default_calls_limit()) { err!(SerializeError::DefaultRecursionLimit) } #[cfg(not(Py_3_10))] let default_obj = ffi!(PyObject_CallFunctionObjArgs( callable.as_ptr(), self.previous.ptr, core::ptr::null_mut() as *mut pyo3_ffi::PyObject )); #[cfg(Py_3_10)] let default_obj = unsafe { pyo3_ffi::PyObject_Vectorcall( callable.as_ptr(), core::ptr::addr_of!(self.previous.ptr), pyo3_ffi::PyVectorcall_NARGS(1) as usize, core::ptr::null_mut(), ) }; if unlikely!(default_obj.is_null()) { err!(SerializeError::UnsupportedType(nonnull!(self.previous.ptr))) } else { let res = PyObjectSerializer::new( default_obj, self.previous.state.copy_for_default_call(), self.previous.default, ) .serialize(serializer); ffi!(Py_DECREF(default_obj)); res } } None => err!(SerializeError::UnsupportedType(nonnull!(self.previous.ptr))), } } } orjson-3.9.15/src/serialize/per_type/dict.rs000066400000000000000000000343711456615046100210410ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::*; use crate::serialize::error::SerializeError; use crate::serialize::obtype::{pyobject_to_obtype, ObType}; use crate::serialize::per_type::{ BoolSerializer, Date, DateTime, DateTimeBuffer, DateTimeLike, FloatSerializer, Int53Serializer, IntSerializer, ListTupleSerializer, NoneSerializer, StrSerializer, Time, ZeroListSerializer, UUID, }; use crate::serialize::serializer::PyObjectSerializer; use crate::serialize::state::SerializerState; use crate::str::{unicode_to_str, unicode_to_str_via_ffi}; use crate::typeref::{ BOOL_TYPE, DATETIME_TYPE, DICT_TYPE, FLOAT_TYPE, INT_TYPE, LIST_TYPE, NONE_TYPE, STR_TYPE, TRUE, VALUE_STR, }; use compact_str::CompactString; use core::ptr::NonNull; use serde::ser::{Serialize, SerializeMap, Serializer}; use smallvec::SmallVec; pub struct ZeroDictSerializer; impl ZeroDictSerializer { pub const fn new() -> Self { Self {} } } impl Serialize for ZeroDictSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_bytes(b"{}") } } pub struct DictGenericSerializer { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl DictGenericSerializer { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { DictGenericSerializer { ptr: ptr, state: state.copy_for_recursive_call(), default: default, } } } impl Serialize for DictGenericSerializer { #[inline] fn serialize(&self, serializer: S) -> Result where S: Serializer, { if unlikely!(self.state.recursion_limit()) { err!(SerializeError::RecursionLimit) } if ffi!(Py_SIZE(self.ptr)) == 0 { ZeroDictSerializer::new().serialize(serializer) } else if opt_disabled!(self.state.opts(), SORT_OR_NON_STR_KEYS) { Dict::new(self.ptr, self.state, self.default).serialize(serializer) } else if opt_enabled!(self.state.opts(), NON_STR_KEYS) { DictNonStrKey::new(self.ptr, self.state, self.default).serialize(serializer) } else { DictSortedKey::new(self.ptr, self.state, self.default).serialize(serializer) } } } pub struct Dict { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl Dict { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { Dict { ptr: ptr, state: state, default: default, } } } impl Serialize for Dict { fn serialize(&self, serializer: S) -> Result where S: Serializer, { debug_assert!(ffi!(Py_SIZE(self.ptr)) > 0); let mut map = serializer.serialize_map(None).unwrap(); let mut next_key: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut next_value: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut pos = 0; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); for _ in 0..=ffi!(Py_SIZE(self.ptr)) as usize - 1 { let key = next_key; let value = next_value; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); // key { let key_ob_type = ob_type!(key); if unlikely!(!is_class_by_type!(key_ob_type, STR_TYPE)) { err!(SerializeError::KeyMustBeStr) } let key_as_str = unicode_to_str(key); if unlikely!(key_as_str.is_none()) { err!(SerializeError::InvalidStr) } map.serialize_key(key_as_str.unwrap()).unwrap(); } // value { let value_ob_type = ob_type!(value); if is_class_by_type!(value_ob_type, STR_TYPE) { map.serialize_value(&StrSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, INT_TYPE) { if unlikely!(opt_enabled!(self.state.opts(), STRICT_INTEGER)) { map.serialize_value(&Int53Serializer::new(value))?; } else { map.serialize_value(&IntSerializer::new(value))?; } } else if is_class_by_type!(value_ob_type, BOOL_TYPE) { map.serialize_value(&BoolSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, NONE_TYPE) { map.serialize_value(&NoneSerializer::new())?; } else if is_class_by_type!(value_ob_type, FLOAT_TYPE) { map.serialize_value(&FloatSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, DICT_TYPE) { let pyvalue = DictGenericSerializer::new(value, self.state, self.default); map.serialize_value(&pyvalue)?; } else if is_class_by_type!(value_ob_type, LIST_TYPE) { if ffi!(Py_SIZE(value)) == 0 { map.serialize_value(&ZeroListSerializer::new())?; } else { let pyvalue = ListTupleSerializer::from_list(value, self.state, self.default); map.serialize_value(&pyvalue)?; } } else if is_class_by_type!(value_ob_type, DATETIME_TYPE) && opt_disabled!(self.state.opts(), PASSTHROUGH_DATETIME) { map.serialize_value(&DateTime::new(value, self.state.opts()))?; } else { let pyvalue = PyObjectSerializer::new(value, self.state, self.default); map.serialize_value(&pyvalue)?; } } } map.end() } } pub struct DictSortedKey { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl DictSortedKey { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { DictSortedKey { ptr: ptr, state: state, default: default, } } } impl Serialize for DictSortedKey { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let len = ffi!(Py_SIZE(self.ptr)) as usize; debug_assert!(len > 0); let mut items: SmallVec<[(&str, *mut pyo3_ffi::PyObject); 8]> = SmallVec::with_capacity(len); let mut next_key: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut next_value: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut pos = 0; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); for _ in 0..=len as usize - 1 { let key = next_key; let value = next_value; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); if unlikely!(unsafe { ob_type!(key) != STR_TYPE }) { err!(SerializeError::KeyMustBeStr) } let data = unicode_to_str(key); if unlikely!(data.is_none()) { err!(SerializeError::InvalidStr) } items.push((data.unwrap(), value)); } items.sort_unstable_by(|a, b| a.0.cmp(b.0)); let mut map = serializer.serialize_map(None).unwrap(); for (key, val) in items.iter() { let pyvalue = PyObjectSerializer::new(*val, self.state, self.default); map.serialize_key(key).unwrap(); map.serialize_value(&pyvalue)?; } map.end() } } pub struct DictNonStrKey { ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, } impl DictNonStrKey { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { DictNonStrKey { ptr: ptr, state: state, default: default, } } fn pyobject_to_string( key: *mut pyo3_ffi::PyObject, opts: crate::opt::Opt, ) -> Result { match pyobject_to_obtype(key, opts) { ObType::None => Ok(CompactString::new_inline("null")), ObType::Bool => { let key_as_str = if unsafe { key == TRUE } { "true" } else { "false" }; Ok(CompactString::from(key_as_str)) } ObType::Int => { let ival = ffi!(PyLong_AsLongLong(key)); if unlikely!(ival == -1 && !ffi!(PyErr_Occurred()).is_null()) { ffi!(PyErr_Clear()); let uval = ffi!(PyLong_AsUnsignedLongLong(key)); if unlikely!(uval == u64::MAX && !ffi!(PyErr_Occurred()).is_null()) { return Err(SerializeError::DictIntegerKey64Bit); } Ok(CompactString::from(itoa::Buffer::new().format(uval))) } else { Ok(CompactString::from(itoa::Buffer::new().format(ival))) } } ObType::Float => { let val = ffi!(PyFloat_AS_DOUBLE(key)); if !val.is_finite() { Ok(CompactString::new_inline("null")) } else { Ok(CompactString::from(ryu::Buffer::new().format_finite(val))) } } ObType::Datetime => { let mut buf = DateTimeBuffer::new(); let dt = DateTime::new(key, opts); if dt.write_buf(&mut buf, opts).is_err() { return Err(SerializeError::DatetimeLibraryUnsupported); } let key_as_str = str_from_slice!(buf.as_ptr(), buf.len()); Ok(CompactString::from(key_as_str)) } ObType::Date => { let mut buf = DateTimeBuffer::new(); Date::new(key).write_buf(&mut buf); let key_as_str = str_from_slice!(buf.as_ptr(), buf.len()); Ok(CompactString::from(key_as_str)) } ObType::Time => { let mut buf = DateTimeBuffer::new(); let time = Time::new(key, opts); if time.write_buf(&mut buf).is_err() { return Err(SerializeError::TimeHasTzinfo); } let key_as_str = str_from_slice!(buf.as_ptr(), buf.len()); Ok(CompactString::from(key_as_str)) } ObType::Uuid => { let mut buf = arrayvec::ArrayVec::::new(); UUID::new(key).write_buf(&mut buf); let key_as_str = str_from_slice!(buf.as_ptr(), buf.len()); Ok(CompactString::from(key_as_str)) } ObType::Enum => { let value = ffi!(PyObject_GetAttr(key, VALUE_STR)); debug_assert!(ffi!(Py_REFCNT(value)) >= 2); let ret = Self::pyobject_to_string(value, opts); ffi!(Py_DECREF(value)); ret } ObType::Str => { // because of ObType::Enum let uni = unicode_to_str(key); if unlikely!(uni.is_none()) { Err(SerializeError::InvalidStr) } else { Ok(CompactString::from(uni.unwrap())) } } ObType::StrSubclass => { let uni = unicode_to_str_via_ffi(key); if unlikely!(uni.is_none()) { Err(SerializeError::InvalidStr) } else { Ok(CompactString::from(uni.unwrap())) } } ObType::Tuple | ObType::NumpyScalar | ObType::NumpyArray | ObType::Dict | ObType::List | ObType::Dataclass | ObType::Fragment | ObType::Unknown => Err(SerializeError::DictKeyInvalidType), } } } impl Serialize for DictNonStrKey { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let len = ffi!(Py_SIZE(self.ptr)) as usize; debug_assert!(len > 0); let mut items: SmallVec<[(CompactString, *mut pyo3_ffi::PyObject); 8]> = SmallVec::with_capacity(len); let opts = self.state.opts() & NOT_PASSTHROUGH; let mut next_key: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut next_value: *mut pyo3_ffi::PyObject = core::ptr::null_mut(); let mut pos = 0; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); for _ in 0..=len - 1 { let key = next_key; let value = next_value; pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value); if is_type!(ob_type!(key), STR_TYPE) { let uni = unicode_to_str(key); if unlikely!(uni.is_none()) { err!(SerializeError::InvalidStr) } items.push((CompactString::from(uni.unwrap()), value)); } else { match Self::pyobject_to_string(key, opts) { Ok(key_as_str) => items.push((key_as_str, value)), Err(err) => err!(err), } } } if opt_enabled!(opts, SORT_KEYS) { items.sort_unstable_by(|a, b| a.0.cmp(&b.0)); } let mut map = serializer.serialize_map(None).unwrap(); for (key, val) in items.iter() { let pyvalue = PyObjectSerializer::new(*val, self.state, self.default); map.serialize_key(key).unwrap(); map.serialize_value(&pyvalue)?; } map.end() } } orjson-3.9.15/src/serialize/per_type/float.rs000066400000000000000000000010401456615046100212060ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct FloatSerializer { ptr: *mut pyo3_ffi::PyObject, } impl FloatSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { FloatSerializer { ptr: ptr } } } impl Serialize for FloatSerializer { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_f64(ffi!(PyFloat_AS_DOUBLE(self.ptr))) } } orjson-3.9.15/src/serialize/per_type/fragment.rs000066400000000000000000000030601456615046100217100ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::ffi::{Fragment, PyBytes_AS_STRING, PyBytes_GET_SIZE}; use crate::serialize::error::SerializeError; use crate::str::unicode_to_str; use crate::typeref::{BYTES_TYPE, STR_TYPE}; use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct FragmentSerializer { ptr: *mut pyo3_ffi::PyObject, } impl FragmentSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { FragmentSerializer { ptr: ptr } } } impl Serialize for FragmentSerializer { #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let buffer: &[u8]; unsafe { let fragment: *mut Fragment = self.ptr as *mut Fragment; let ob_type = ob_type!((*fragment).contents); if ob_type == BYTES_TYPE { buffer = core::slice::from_raw_parts( PyBytes_AS_STRING((*fragment).contents) as *const u8, PyBytes_GET_SIZE((*fragment).contents) as usize, ); } else if ob_type == STR_TYPE { let uni = unicode_to_str((*fragment).contents); if unlikely!(uni.is_none()) { err!(SerializeError::InvalidStr) } buffer = uni.unwrap().as_bytes(); } else { err!(SerializeError::InvalidFragment) } } serializer.serialize_bytes(buffer) } } orjson-3.9.15/src/serialize/per_type/int.rs000066400000000000000000000043401456615046100207010ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::ffi::{pylong_is_unsigned, pylong_is_zero, pylong_value_signed, pylong_value_unsigned}; use crate::serialize::error::SerializeError; use serde::ser::{Serialize, Serializer}; // https://tools.ietf.org/html/rfc7159#section-6 // "[-(2**53)+1, (2**53)-1]" const STRICT_INT_MIN: i64 = -9007199254740991; const STRICT_INT_MAX: i64 = 9007199254740991; #[repr(transparent)] pub struct IntSerializer { ptr: *mut pyo3_ffi::PyObject, } impl IntSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { IntSerializer { ptr: ptr } } } impl Serialize for IntSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { if pylong_is_zero(self.ptr) { serializer.serialize_u64(0) } else if pylong_is_unsigned(self.ptr) { let val = pylong_value_unsigned(self.ptr); if unlikely!(val == u64::MAX) && !ffi!(PyErr_Occurred()).is_null() { err!(SerializeError::Integer64Bits) } else { serializer.serialize_u64(val) } } else { let val = pylong_value_signed(self.ptr); if unlikely!(val == -1) && !ffi!(PyErr_Occurred()).is_null() { err!(SerializeError::Integer64Bits) } serializer.serialize_i64(val) } } } #[repr(transparent)] pub struct Int53Serializer { ptr: *mut pyo3_ffi::PyObject, } impl Int53Serializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { Int53Serializer { ptr: ptr } } } impl Serialize for Int53Serializer { #[cold] #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let val = pylong_value_signed(self.ptr); if unlikely!(val == -1) { if ffi!(PyErr_Occurred()).is_null() { serializer.serialize_i64(val) } else { err!(SerializeError::Integer53Bits) } } else if !(STRICT_INT_MIN..=STRICT_INT_MAX).contains(&val) { err!(SerializeError::Integer53Bits) } else { serializer.serialize_i64(val) } } } orjson-3.9.15/src/serialize/per_type/list.rs000066400000000000000000000112201456615046100210550ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::{PASSTHROUGH_DATETIME, STRICT_INTEGER}; use crate::serialize::error::SerializeError; use crate::serialize::per_type::{ BoolSerializer, DateTime, DictGenericSerializer, FloatSerializer, Int53Serializer, IntSerializer, NoneSerializer, StrSerializer, }; use crate::serialize::serializer::PyObjectSerializer; use crate::serialize::state::SerializerState; use crate::typeref::*; use core::ptr::NonNull; use serde::ser::{Serialize, SerializeSeq, Serializer}; pub struct ZeroListSerializer; impl ZeroListSerializer { pub const fn new() -> Self { Self {} } } impl Serialize for ZeroListSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_bytes(b"[]") } } pub struct ListTupleSerializer { data_ptr: *const *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, len: usize, } impl ListTupleSerializer { pub fn from_list( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { debug_assert!( is_type!(ob_type!(ptr), LIST_TYPE) || is_subclass_by_flag!(ob_type!(ptr), Py_TPFLAGS_LIST_SUBCLASS) ); let data_ptr = unsafe { (*(ptr as *mut pyo3_ffi::PyListObject)).ob_item }; let len = ffi!(Py_SIZE(ptr)) as usize; Self { data_ptr: data_ptr, len: len, state: state.copy_for_recursive_call(), default: default, } } pub fn from_tuple( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { debug_assert!( is_type!(ob_type!(ptr), TUPLE_TYPE) || is_subclass_by_flag!(ob_type!(ptr), Py_TPFLAGS_TUPLE_SUBCLASS) ); let data_ptr = unsafe { (*(ptr as *mut pyo3_ffi::PyTupleObject)).ob_item.as_ptr() }; let len = ffi!(Py_SIZE(ptr)) as usize; Self { data_ptr: data_ptr, len: len, state: state.copy_for_recursive_call(), default: default, } } } impl Serialize for ListTupleSerializer { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { if unlikely!(self.state.recursion_limit()) { err!(SerializeError::RecursionLimit) } debug_assert!(self.len >= 1); let mut seq = serializer.serialize_seq(None).unwrap(); for idx in 0..=self.len - 1 { let value = unsafe { *((self.data_ptr).add(idx)) }; let value_ob_type = ob_type!(value); if is_class_by_type!(value_ob_type, STR_TYPE) { seq.serialize_element(&StrSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, INT_TYPE) { if unlikely!(opt_enabled!(self.state.opts(), STRICT_INTEGER)) { seq.serialize_element(&Int53Serializer::new(value))?; } else { seq.serialize_element(&IntSerializer::new(value))?; } } else if is_class_by_type!(value_ob_type, BOOL_TYPE) { seq.serialize_element(&BoolSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, NONE_TYPE) { seq.serialize_element(&NoneSerializer::new())?; } else if is_class_by_type!(value_ob_type, FLOAT_TYPE) { seq.serialize_element(&FloatSerializer::new(value))?; } else if is_class_by_type!(value_ob_type, DICT_TYPE) { let pyvalue = DictGenericSerializer::new(value, self.state, self.default); seq.serialize_element(&pyvalue)?; } else if is_class_by_type!(value_ob_type, LIST_TYPE) { if ffi!(Py_SIZE(value)) == 0 { seq.serialize_element(&ZeroListSerializer::new())?; } else { let pyvalue = ListTupleSerializer::from_list(value, self.state, self.default); seq.serialize_element(&pyvalue)?; } } else if is_class_by_type!(value_ob_type, DATETIME_TYPE) && opt_disabled!(self.state.opts(), PASSTHROUGH_DATETIME) { seq.serialize_element(&DateTime::new(value, self.state.opts()))?; } else { let pyvalue = PyObjectSerializer::new(value, self.state, self.default); seq.serialize_element(&pyvalue)?; } } seq.end() } } orjson-3.9.15/src/serialize/per_type/mod.rs000066400000000000000000000016151456615046100206700ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) mod dataclass; mod datetime; mod pybool; #[macro_use] mod datetimelike; mod default; mod dict; mod float; mod fragment; mod int; mod list; mod none; mod numpy; mod pyenum; mod unicode; mod uuid; pub use dataclass::DataclassGenericSerializer; pub use datetime::{Date, DateTime, Time}; pub use datetimelike::{DateTimeBuffer, DateTimeError, DateTimeLike, Offset}; pub use default::DefaultSerializer; pub use dict::DictGenericSerializer; pub use float::FloatSerializer; pub use fragment::FragmentSerializer; pub use int::{Int53Serializer, IntSerializer}; pub use list::{ListTupleSerializer, ZeroListSerializer}; pub use none::NoneSerializer; pub use numpy::{is_numpy_array, is_numpy_scalar, NumpyScalar, NumpySerializer}; pub use pybool::BoolSerializer; pub use pyenum::EnumSerializer; pub use unicode::{StrSerializer, StrSubclassSerializer}; pub use uuid::UUID; orjson-3.9.15/src/serialize/per_type/none.rs000066400000000000000000000006211456615046100210440ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use serde::ser::{Serialize, Serializer}; pub struct NoneSerializer; impl NoneSerializer { pub const fn new() -> Self { Self {} } } impl Serialize for NoneSerializer { #[inline] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_unit() } } orjson-3.9.15/src/serialize/per_type/numpy.rs000066400000000000000000001050251456615046100212610ustar00rootroot00000000000000use crate::opt::*; use crate::serialize::error::SerializeError; use crate::serialize::per_type::{ DateTimeBuffer, DateTimeError, DateTimeLike, DefaultSerializer, Offset, ZeroListSerializer, }; use crate::serialize::serializer::PyObjectSerializer; use crate::typeref::{load_numpy_types, ARRAY_STRUCT_STR, DESCR_STR, DTYPE_STR, NUMPY_TYPES}; use chrono::{Datelike, NaiveDate, NaiveDateTime, Timelike}; use core::ffi::{c_char, c_int, c_void}; use pyo3_ffi::*; use serde::ser::{self, Serialize, SerializeSeq, Serializer}; use std::fmt; #[repr(transparent)] pub struct NumpySerializer<'a> { previous: &'a PyObjectSerializer, } impl<'a> NumpySerializer<'a> { pub fn new(previous: &'a PyObjectSerializer) -> Self { Self { previous: previous } } } impl<'a> Serialize for NumpySerializer<'a> { #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn serialize(&self, serializer: S) -> Result where S: Serializer, { match NumpyArray::new(self.previous.ptr, self.previous.state.opts()) { Ok(val) => val.serialize(serializer), Err(PyArrayError::Malformed) => err!(SerializeError::NumpyMalformed), Err(PyArrayError::NotContiguous) | Err(PyArrayError::UnsupportedDataType) if self.previous.default.is_some() => { DefaultSerializer::new(self.previous).serialize(serializer) } Err(PyArrayError::NotContiguous) => { err!(SerializeError::NumpyNotCContiguous) } Err(PyArrayError::UnsupportedDataType) => { err!(SerializeError::NumpyUnsupportedDatatype) } } } } macro_rules! slice { ($ptr:expr, $size:expr) => { unsafe { core::slice::from_raw_parts($ptr, $size) } }; } #[cold] pub fn is_numpy_scalar(ob_type: *mut PyTypeObject) -> bool { let numpy_types = unsafe { NUMPY_TYPES.get_or_init(load_numpy_types) }; if numpy_types.is_none() { false } else { let scalar_types = unsafe { numpy_types.unwrap().as_ref() }; ob_type == scalar_types.float64 || ob_type == scalar_types.float32 || ob_type == scalar_types.int64 || ob_type == scalar_types.int16 || ob_type == scalar_types.int32 || ob_type == scalar_types.int8 || ob_type == scalar_types.uint64 || ob_type == scalar_types.uint32 || ob_type == scalar_types.uint8 || ob_type == scalar_types.uint16 || ob_type == scalar_types.bool_ || ob_type == scalar_types.datetime64 } } #[cold] pub fn is_numpy_array(ob_type: *mut PyTypeObject) -> bool { let numpy_types = unsafe { NUMPY_TYPES.get_or_init(load_numpy_types) }; if numpy_types.is_none() { false } else { let scalar_types = unsafe { numpy_types.unwrap().as_ref() }; unsafe { ob_type == scalar_types.array } } } #[repr(C)] pub struct PyCapsule { pub ob_refcnt: Py_ssize_t, pub ob_type: *mut PyTypeObject, pub pointer: *mut c_void, pub name: *const c_char, pub context: *mut c_void, pub destructor: *mut c_void, // should be typedef void (*PyCapsule_Destructor)(PyObject *); } // https://docs.scipy.org/doc/numpy/reference/arrays.interface.html#c.__array_struct__ #[repr(C)] pub struct PyArrayInterface { pub two: c_int, pub nd: c_int, pub typekind: c_char, pub itemsize: c_int, pub flags: c_int, pub shape: *mut Py_intptr_t, pub strides: *mut Py_intptr_t, pub data: *mut c_void, pub descr: *mut PyObject, } #[derive(Clone, Copy)] pub enum ItemType { BOOL, DATETIME64(NumpyDatetimeUnit), F32, F64, I8, I16, I32, I64, U8, U16, U32, U64, } impl ItemType { fn find(array: *mut PyArrayInterface, ptr: *mut PyObject) -> Option { match unsafe { ((*array).typekind, (*array).itemsize) } { (098, 1) => Some(ItemType::BOOL), (077, 8) => { let unit = NumpyDatetimeUnit::from_pyobject(ptr); Some(ItemType::DATETIME64(unit)) } (102, 4) => Some(ItemType::F32), (102, 8) => Some(ItemType::F64), (105, 1) => Some(ItemType::I8), (105, 2) => Some(ItemType::I16), (105, 4) => Some(ItemType::I32), (105, 8) => Some(ItemType::I64), (117, 1) => Some(ItemType::U8), (117, 2) => Some(ItemType::U16), (117, 4) => Some(ItemType::U32), (117, 8) => Some(ItemType::U64), _ => None, } } } pub enum PyArrayError { Malformed, NotContiguous, UnsupportedDataType, } // >>> arr = numpy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], numpy.int32) // >>> arr.ndim // 3 // >>> arr.shape // (2, 2, 2) // >>> arr.strides // (16, 8, 4) pub struct NumpyArray { array: *mut PyArrayInterface, position: Vec, children: Vec, depth: usize, capsule: *mut PyCapsule, kind: ItemType, opts: Opt, } impl NumpyArray { #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] pub fn new(ptr: *mut PyObject, opts: Opt) -> Result { let capsule = ffi!(PyObject_GetAttr(ptr, ARRAY_STRUCT_STR)); let array = unsafe { (*(capsule as *mut PyCapsule)).pointer as *mut PyArrayInterface }; if unsafe { (*array).two != 2 } { ffi!(Py_DECREF(capsule)); Err(PyArrayError::Malformed) } else if unsafe { (*array).flags } & 0x1 != 0x1 { ffi!(Py_DECREF(capsule)); Err(PyArrayError::NotContiguous) } else { let num_dimensions = unsafe { (*array).nd as usize }; if num_dimensions == 0 { ffi!(Py_DECREF(capsule)); return Err(PyArrayError::UnsupportedDataType); } match ItemType::find(array, ptr) { None => { ffi!(Py_DECREF(capsule)); Err(PyArrayError::UnsupportedDataType) } Some(kind) => { let mut pyarray = NumpyArray { array: array, position: vec![0; num_dimensions], children: Vec::with_capacity(num_dimensions), depth: 0, capsule: capsule as *mut PyCapsule, kind: kind, opts, }; if pyarray.dimensions() > 1 { pyarray.build(); } Ok(pyarray) } } } } #[cfg_attr(feature = "optimize", optimize(size))] fn child_from_parent(&self, position: Vec, num_children: usize) -> Self { let mut arr = NumpyArray { array: self.array, position: position, children: Vec::with_capacity(num_children), depth: self.depth + 1, capsule: self.capsule, kind: self.kind, opts: self.opts, }; arr.build(); arr } #[cfg_attr(feature = "optimize", optimize(size))] fn build(&mut self) { if self.depth < self.dimensions() - 1 { for i in 0..=self.shape()[self.depth] - 1 { let mut position: Vec = self.position.to_vec(); position[self.depth] = i; let num_children: usize = if self.depth < self.dimensions() - 2 { self.shape()[self.depth + 1] as usize } else { 0 }; self.children .push(self.child_from_parent(position, num_children)) } } } fn data(&self) -> *const c_void { let offset = self .strides() .iter() .zip(self.position.iter().copied()) .take(self.depth) .map(|(a, b)| a * b) .sum::(); unsafe { (*self.array).data.offset(offset) } } fn num_items(&self) -> usize { self.shape()[self.shape().len() - 1] as usize } fn dimensions(&self) -> usize { unsafe { (*self.array).nd as usize } } fn shape(&self) -> &[isize] { slice!((*self.array).shape as *const isize, self.dimensions()) } fn strides(&self) -> &[isize] { slice!((*self.array).strides as *const isize, self.dimensions()) } } impl Drop for NumpyArray { fn drop(&mut self) { if self.depth == 0 { ffi!(Py_DECREF(self.array as *mut pyo3_ffi::PyObject)); ffi!(Py_DECREF(self.capsule as *mut pyo3_ffi::PyObject)); } } } impl Serialize for NumpyArray { #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn serialize(&self, serializer: S) -> Result where S: Serializer, { if unlikely!(!(self.depth >= self.dimensions() || self.shape()[self.depth] != 0)) { ZeroListSerializer::new().serialize(serializer) } else if !self.children.is_empty() { let mut seq = serializer.serialize_seq(None).unwrap(); for child in &self.children { seq.serialize_element(child).unwrap(); } seq.end() } else { match self.kind { ItemType::F64 => { NumpyF64Array::new(slice!(self.data() as *const f64, self.num_items())) .serialize(serializer) } ItemType::F32 => { NumpyF32Array::new(slice!(self.data() as *const f32, self.num_items())) .serialize(serializer) } ItemType::U64 => { NumpyU64Array::new(slice!(self.data() as *const u64, self.num_items())) .serialize(serializer) } ItemType::U32 => { NumpyU32Array::new(slice!(self.data() as *const u32, self.num_items())) .serialize(serializer) } ItemType::U16 => { NumpyU16Array::new(slice!(self.data() as *const u16, self.num_items())) .serialize(serializer) } ItemType::U8 => { NumpyU8Array::new(slice!(self.data() as *const u8, self.num_items())) .serialize(serializer) } ItemType::I64 => { NumpyI64Array::new(slice!(self.data() as *const i64, self.num_items())) .serialize(serializer) } ItemType::I32 => { NumpyI32Array::new(slice!(self.data() as *const i32, self.num_items())) .serialize(serializer) } ItemType::I16 => { NumpyI16Array::new(slice!(self.data() as *const i16, self.num_items())) .serialize(serializer) } ItemType::I8 => { NumpyI8Array::new(slice!(self.data() as *const i8, self.num_items())) .serialize(serializer) } ItemType::BOOL => { NumpyBoolArray::new(slice!(self.data() as *const u8, self.num_items())) .serialize(serializer) } ItemType::DATETIME64(unit) => NumpyDatetime64Array::new( slice!(self.data() as *const i64, self.num_items()), unit, self.opts, ) .serialize(serializer), } } } } #[repr(transparent)] struct NumpyF64Array<'a> { data: &'a [f64], } impl<'a> NumpyF64Array<'a> { fn new(data: &'a [f64]) -> Self { Self { data } } } impl<'a> Serialize for NumpyF64Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeF64 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeF64 { obj: f64, } impl Serialize for DataTypeF64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_f64(self.obj) } } #[repr(transparent)] struct NumpyF32Array<'a> { data: &'a [f32], } impl<'a> NumpyF32Array<'a> { fn new(data: &'a [f32]) -> Self { Self { data } } } impl<'a> Serialize for NumpyF32Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeF32 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] struct DataTypeF32 { obj: f32, } impl Serialize for DataTypeF32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_f32(self.obj) } } #[repr(transparent)] struct NumpyU64Array<'a> { data: &'a [u64], } impl<'a> NumpyU64Array<'a> { fn new(data: &'a [u64]) -> Self { Self { data } } } impl<'a> Serialize for NumpyU64Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeU64 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeU64 { obj: u64, } impl Serialize for DataTypeU64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u64(self.obj) } } #[repr(transparent)] struct NumpyU32Array<'a> { data: &'a [u32], } impl<'a> NumpyU32Array<'a> { fn new(data: &'a [u32]) -> Self { Self { data } } } impl<'a> Serialize for NumpyU32Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeU32 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeU32 { obj: u32, } impl Serialize for DataTypeU32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u32(self.obj) } } #[repr(transparent)] struct NumpyU16Array<'a> { data: &'a [u16], } impl<'a> NumpyU16Array<'a> { fn new(data: &'a [u16]) -> Self { Self { data } } } impl<'a> Serialize for NumpyU16Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeU16 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeU16 { obj: u16, } impl Serialize for DataTypeU16 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u16(self.obj) } } #[repr(transparent)] struct NumpyI64Array<'a> { data: &'a [i64], } impl<'a> NumpyI64Array<'a> { fn new(data: &'a [i64]) -> Self { Self { data } } } impl<'a> Serialize for NumpyI64Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeI64 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeI64 { obj: i64, } impl Serialize for DataTypeI64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i64(self.obj) } } #[repr(transparent)] struct NumpyI32Array<'a> { data: &'a [i32], } impl<'a> NumpyI32Array<'a> { fn new(data: &'a [i32]) -> Self { Self { data } } } impl<'a> Serialize for NumpyI32Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeI32 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeI32 { obj: i32, } impl Serialize for DataTypeI32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i32(self.obj) } } #[repr(transparent)] struct NumpyI16Array<'a> { data: &'a [i16], } impl<'a> NumpyI16Array<'a> { fn new(data: &'a [i16]) -> Self { Self { data } } } impl<'a> Serialize for NumpyI16Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeI16 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeI16 { obj: i16, } impl Serialize for DataTypeI16 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i16(self.obj) } } #[repr(transparent)] struct NumpyI8Array<'a> { data: &'a [i8], } impl<'a> NumpyI8Array<'a> { fn new(data: &'a [i8]) -> Self { Self { data } } } impl<'a> Serialize for NumpyI8Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeI8 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeI8 { obj: i8, } impl Serialize for DataTypeI8 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i8(self.obj) } } #[repr(transparent)] struct NumpyU8Array<'a> { data: &'a [u8], } impl<'a> NumpyU8Array<'a> { fn new(data: &'a [u8]) -> Self { Self { data } } } impl<'a> Serialize for NumpyU8Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeU8 { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeU8 { obj: u8, } impl Serialize for DataTypeU8 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u8(self.obj) } } #[repr(transparent)] struct NumpyBoolArray<'a> { data: &'a [u8], } impl<'a> NumpyBoolArray<'a> { fn new(data: &'a [u8]) -> Self { Self { data } } } impl<'a> Serialize for NumpyBoolArray<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { seq.serialize_element(&DataTypeBool { obj: each }).unwrap(); } seq.end() } } #[repr(transparent)] pub struct DataTypeBool { obj: u8, } impl Serialize for DataTypeBool { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_bool(self.obj == 1) } } pub struct NumpyScalar { ptr: *mut pyo3_ffi::PyObject, opts: Opt, } impl NumpyScalar { pub fn new(ptr: *mut PyObject, opts: Opt) -> Self { NumpyScalar { ptr, opts } } } impl Serialize for NumpyScalar { #[cold] #[inline(never)] #[cfg_attr(feature = "optimize", optimize(size))] fn serialize(&self, serializer: S) -> Result where S: Serializer, { unsafe { let ob_type = ob_type!(self.ptr); let scalar_types = unsafe { NUMPY_TYPES.get_or_init(load_numpy_types).unwrap().as_ref() }; if ob_type == scalar_types.float64 { (*(self.ptr as *mut NumpyFloat64)).serialize(serializer) } else if ob_type == scalar_types.float32 { (*(self.ptr as *mut NumpyFloat32)).serialize(serializer) } else if ob_type == scalar_types.int64 { (*(self.ptr as *mut NumpyInt64)).serialize(serializer) } else if ob_type == scalar_types.int32 { (*(self.ptr as *mut NumpyInt32)).serialize(serializer) } else if ob_type == scalar_types.int16 { (*(self.ptr as *mut NumpyInt16)).serialize(serializer) } else if ob_type == scalar_types.int8 { (*(self.ptr as *mut NumpyInt8)).serialize(serializer) } else if ob_type == scalar_types.uint64 { (*(self.ptr as *mut NumpyUint64)).serialize(serializer) } else if ob_type == scalar_types.uint32 { (*(self.ptr as *mut NumpyUint32)).serialize(serializer) } else if ob_type == scalar_types.uint16 { (*(self.ptr as *mut NumpyUint16)).serialize(serializer) } else if ob_type == scalar_types.uint8 { (*(self.ptr as *mut NumpyUint8)).serialize(serializer) } else if ob_type == scalar_types.bool_ { (*(self.ptr as *mut NumpyBool)).serialize(serializer) } else if ob_type == scalar_types.datetime64 { let unit = NumpyDatetimeUnit::from_pyobject(self.ptr); let obj = &*(self.ptr as *mut NumpyDatetime64); let dt = unit .datetime(obj.value, self.opts) .map_err(NumpyDateTimeError::into_serde_err)?; dt.serialize(serializer) } else { unreachable!() } } } } #[repr(C)] pub struct NumpyInt8 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: i8, } impl Serialize for NumpyInt8 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i8(self.value) } } #[repr(C)] pub struct NumpyInt16 { pub ob_refcnt: Py_ssize_t, pub ob_type: *mut PyTypeObject, pub value: i16, } impl Serialize for NumpyInt16 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i16(self.value) } } #[repr(C)] pub struct NumpyInt32 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: i32, } impl Serialize for NumpyInt32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i32(self.value) } } #[repr(C)] pub struct NumpyInt64 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: i64, } impl Serialize for NumpyInt64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_i64(self.value) } } #[repr(C)] pub struct NumpyUint8 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: u8, } impl Serialize for NumpyUint8 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u8(self.value) } } #[repr(C)] pub struct NumpyUint16 { pub ob_refcnt: Py_ssize_t, pub ob_type: *mut PyTypeObject, pub value: u16, } impl Serialize for NumpyUint16 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u16(self.value) } } #[repr(C)] pub struct NumpyUint32 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: u32, } impl Serialize for NumpyUint32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u32(self.value) } } #[repr(C)] pub struct NumpyUint64 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: u64, } impl Serialize for NumpyUint64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_u64(self.value) } } #[repr(C)] pub struct NumpyFloat32 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: f32, } impl Serialize for NumpyFloat32 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_f32(self.value) } } #[repr(C)] pub struct NumpyFloat64 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: f64, } impl Serialize for NumpyFloat64 { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_f64(self.value) } } #[repr(C)] pub struct NumpyBool { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: bool, } impl Serialize for NumpyBool { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_bool(self.value) } } /// This mimicks the units supported by numpy's datetime64 type. /// /// See /// https://github.com/numpy/numpy/blob/fc8e3bbe419748ac5c6b7f3d0845e4bafa74644b/numpy/core/include/numpy/ndarraytypes.h#L268-L282. #[derive(Clone, Copy)] pub enum NumpyDatetimeUnit { NaT, Years, Months, Weeks, Days, Hours, Minutes, Seconds, Milliseconds, Microseconds, Nanoseconds, Picoseconds, Femtoseconds, Attoseconds, Generic, } impl fmt::Display for NumpyDatetimeUnit { #[cold] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let unit = match self { Self::NaT => "NaT", Self::Years => "years", Self::Months => "months", Self::Weeks => "weeks", Self::Days => "days", Self::Hours => "hours", Self::Minutes => "minutes", Self::Seconds => "seconds", Self::Milliseconds => "milliseconds", Self::Microseconds => "microseconds", Self::Nanoseconds => "nanoseconds", Self::Picoseconds => "picoseconds", Self::Femtoseconds => "femtoseconds", Self::Attoseconds => "attoseconds", Self::Generic => "generic", }; write!(f, "{}", unit) } } #[derive(Clone, Copy)] enum NumpyDateTimeError { UnsupportedUnit(NumpyDatetimeUnit), Unrepresentable { unit: NumpyDatetimeUnit, val: i64 }, } impl NumpyDateTimeError { #[cold] fn into_serde_err(self) -> T { let err = match self { Self::UnsupportedUnit(unit) => format!("unsupported numpy.datetime64 unit: {}", unit), Self::Unrepresentable { unit, val } => { format!("unrepresentable numpy.datetime64: {} {}", val, unit) } }; ser::Error::custom(err) } } impl NumpyDatetimeUnit { /// Create a `NumpyDatetimeUnit` from a pointer to a Python object holding a /// numpy array. /// /// This function must only be called with pointers to numpy arrays. /// /// We need to look inside the `obj.dtype.descr` attribute of the Python /// object rather than using the `descr` field of the `__array_struct__` /// because that field isn't populated for datetime64 arrays; see /// https://github.com/numpy/numpy/issues/5350. #[cold] #[cfg_attr(feature = "optimize", optimize(size))] fn from_pyobject(ptr: *mut PyObject) -> Self { let dtype = ffi!(PyObject_GetAttr(ptr, DTYPE_STR)); let descr = ffi!(PyObject_GetAttr(dtype, DESCR_STR)); let el0 = ffi!(PyList_GET_ITEM(descr, 0)); let descr_str = ffi!(PyTuple_GET_ITEM(el0, 1)); let uni = crate::str::unicode_to_str(descr_str).unwrap(); if uni.len() < 5 { return Self::NaT; } // unit descriptions are found at // https://github.com/numpy/numpy/blob/b235f9e701e14ed6f6f6dcba885f7986a833743f/numpy/core/src/multiarray/datetime.c#L79-L96. let ret = match &uni[4..uni.len() - 1] { "Y" => Self::Years, "M" => Self::Months, "W" => Self::Weeks, "D" => Self::Days, "h" => Self::Hours, "m" => Self::Minutes, "s" => Self::Seconds, "ms" => Self::Milliseconds, "us" => Self::Microseconds, "ns" => Self::Nanoseconds, "ps" => Self::Picoseconds, "fs" => Self::Femtoseconds, "as" => Self::Attoseconds, "generic" => Self::Generic, _ => unreachable!(), }; ffi!(Py_DECREF(dtype)); ffi!(Py_DECREF(descr)); ret } /// Return a `NumpyDatetime64Repr` for a value in array with this unit. /// /// Returns an `Err(NumpyDateTimeError)` if the value is invalid for this unit. #[cold] #[cfg_attr(feature = "optimize", optimize(size))] fn datetime(&self, val: i64, opts: Opt) -> Result { match self { Self::Years => Ok(NaiveDate::from_ymd_opt( (val + 1970) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, 1, 1, ) .unwrap() .and_hms_opt(0, 0, 0) .unwrap()), Self::Months => Ok(NaiveDate::from_ymd_opt( (val / 12 + 1970) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, (val % 12 + 1) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, 1, ) .unwrap() .and_hms_opt(0, 0, 0) .unwrap()), Self::Weeks => { Ok(NaiveDateTime::from_timestamp_opt(val * 7 * 24 * 60 * 60, 0).unwrap()) } Self::Days => Ok(NaiveDateTime::from_timestamp_opt(val * 24 * 60 * 60, 0).unwrap()), Self::Hours => Ok(NaiveDateTime::from_timestamp_opt(val * 60 * 60, 0).unwrap()), Self::Minutes => Ok(NaiveDateTime::from_timestamp_opt(val * 60, 0).unwrap()), Self::Seconds => Ok(NaiveDateTime::from_timestamp_opt(val, 0).unwrap()), Self::Milliseconds => Ok(NaiveDateTime::from_timestamp_opt( val / 1_000, (val % 1_000 * 1_000_000) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, ) .unwrap()), Self::Microseconds => Ok(NaiveDateTime::from_timestamp_opt( val / 1_000_000, (val % 1_000_000 * 1_000) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, ) .unwrap()), Self::Nanoseconds => Ok(NaiveDateTime::from_timestamp_opt( val / 1_000_000_000, (val % 1_000_000_000) .try_into() .map_err(|_| NumpyDateTimeError::Unrepresentable { unit: *self, val })?, ) .unwrap()), _ => Err(NumpyDateTimeError::UnsupportedUnit(*self)), } .map(|dt| NumpyDatetime64Repr { dt, opts }) } } struct NumpyDatetime64Array<'a> { data: &'a [i64], unit: NumpyDatetimeUnit, opts: Opt, } impl<'a> NumpyDatetime64Array<'a> { fn new(data: &'a [i64], unit: NumpyDatetimeUnit, opts: Opt) -> Self { Self { data, unit, opts } } } impl<'a> Serialize for NumpyDatetime64Array<'a> { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(None).unwrap(); for &each in self.data.iter() { let dt = self .unit .datetime(each, self.opts) .map_err(NumpyDateTimeError::into_serde_err)?; seq.serialize_element(&dt).unwrap(); } seq.end() } } #[repr(C)] pub struct NumpyDatetime64 { ob_refcnt: Py_ssize_t, ob_type: *mut PyTypeObject, value: i64, } macro_rules! forward_inner { ($meth: ident, $ty: ident) => { fn $meth(&self) -> $ty { self.dt.$meth() as $ty } }; } struct NumpyDatetime64Repr { dt: NaiveDateTime, opts: Opt, } impl DateTimeLike for NumpyDatetime64Repr { forward_inner!(year, i32); forward_inner!(month, u8); forward_inner!(day, u8); forward_inner!(hour, u8); forward_inner!(minute, u8); forward_inner!(second, u8); forward_inner!(nanosecond, u32); fn microsecond(&self) -> u32 { self.nanosecond() / 1_000 } fn has_tz(&self) -> bool { false } fn slow_offset(&self) -> Result { unreachable!() } fn offset(&self) -> Result { Ok(Offset::default()) } } impl Serialize for NumpyDatetime64Repr { #[cold] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut buf = DateTimeBuffer::new(); let _ = self.write_buf(&mut buf, self.opts); serializer.collect_str(str_from_slice!(buf.as_ptr(), buf.len())) } } orjson-3.9.15/src/serialize/per_type/pybool.rs000066400000000000000000000010401456615046100214050ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct BoolSerializer { ptr: *mut pyo3_ffi::PyObject, } impl BoolSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { BoolSerializer { ptr: ptr } } } impl Serialize for BoolSerializer { #[inline] fn serialize(&self, serializer: S) -> Result where S: Serializer, { serializer.serialize_bool(unsafe { self.ptr == crate::typeref::TRUE }) } } orjson-3.9.15/src/serialize/per_type/pyenum.rs000066400000000000000000000015641456615046100214310ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::serialize::serializer::PyObjectSerializer; use crate::typeref::VALUE_STR; use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct EnumSerializer<'a> { previous: &'a PyObjectSerializer, } impl<'a> EnumSerializer<'a> { pub fn new(previous: &'a PyObjectSerializer) -> Self { Self { previous: previous } } } impl<'a> Serialize for EnumSerializer<'a> { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let value = ffi!(PyObject_GetAttr(self.previous.ptr, VALUE_STR)); debug_assert!(ffi!(Py_REFCNT(value)) >= 2); let ret = PyObjectSerializer::new(value, self.previous.state, self.previous.default) .serialize(serializer); ffi!(Py_DECREF(value)); ret } } orjson-3.9.15/src/serialize/per_type/unicode.rs000066400000000000000000000025071456615046100215400ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::serialize::error::SerializeError; use crate::str::{unicode_to_str, unicode_to_str_via_ffi}; use serde::ser::{Serialize, Serializer}; #[repr(transparent)] pub struct StrSerializer { ptr: *mut pyo3_ffi::PyObject, } impl StrSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { StrSerializer { ptr: ptr } } } impl Serialize for StrSerializer { #[inline] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let uni = unicode_to_str(self.ptr); if unlikely!(uni.is_none()) { err!(SerializeError::InvalidStr) } serializer.serialize_str(uni.unwrap()) } } #[repr(transparent)] pub struct StrSubclassSerializer { ptr: *mut pyo3_ffi::PyObject, } impl StrSubclassSerializer { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { StrSubclassSerializer { ptr: ptr } } } impl Serialize for StrSubclassSerializer { #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let uni = unicode_to_str_via_ffi(self.ptr); if unlikely!(uni.is_none()) { err!(SerializeError::InvalidStr) } serializer.serialize_str(uni.unwrap()) } } orjson-3.9.15/src/serialize/per_type/uuid.rs000066400000000000000000000037201456615046100210560ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::typeref::INT_ATTR_STR; use core::ffi::c_uchar; use serde::ser::{Serialize, Serializer}; use std::io::Write; pub type UUIDBuffer = arrayvec::ArrayVec; #[repr(transparent)] pub struct UUID { ptr: *mut pyo3_ffi::PyObject, } impl UUID { pub fn new(ptr: *mut pyo3_ffi::PyObject) -> Self { UUID { ptr: ptr } } pub fn write_buf(&self, buf: &mut UUIDBuffer) { let value: u128; { // test_uuid_immutable, test_uuid_int let py_int = ffi!(PyObject_GetAttr(self.ptr, INT_ATTR_STR)); ffi!(Py_DECREF(py_int)); let buffer: [c_uchar; 16] = [0; 16]; unsafe { // test_uuid_overflow pyo3_ffi::_PyLong_AsByteArray( py_int as *mut pyo3_ffi::PyLongObject, buffer.as_ptr() as *mut c_uchar, 16, 1, // little_endian 0, // is_signed ) }; value = u128::from_le_bytes(buffer); } let mut hexadecimal = arrayvec::ArrayVec::::new(); write!(hexadecimal, "{:032x}", value).unwrap(); buf.try_extend_from_slice(&hexadecimal[..8]).unwrap(); buf.push(b'-'); buf.try_extend_from_slice(&hexadecimal[8..12]).unwrap(); buf.push(b'-'); buf.try_extend_from_slice(&hexadecimal[12..16]).unwrap(); buf.push(b'-'); buf.try_extend_from_slice(&hexadecimal[16..20]).unwrap(); buf.push(b'-'); buf.try_extend_from_slice(&hexadecimal[20..32]).unwrap(); } } impl Serialize for UUID { #[cold] #[inline(never)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut buf = arrayvec::ArrayVec::::new(); self.write_buf(&mut buf); serializer.serialize_str(str_from_slice!(buf.as_ptr(), buf.len())) } } orjson-3.9.15/src/serialize/serializer.rs000066400000000000000000000110401456615046100204240ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::{Opt, APPEND_NEWLINE, INDENT_2, STRICT_INTEGER}; use crate::serialize::obtype::{pyobject_to_obtype, ObType}; use crate::serialize::per_type::{ BoolSerializer, DataclassGenericSerializer, Date, DateTime, DefaultSerializer, DictGenericSerializer, EnumSerializer, FloatSerializer, FragmentSerializer, Int53Serializer, IntSerializer, ListTupleSerializer, NoneSerializer, NumpyScalar, NumpySerializer, StrSerializer, StrSubclassSerializer, Time, ZeroListSerializer, UUID, }; use crate::serialize::state::SerializerState; use crate::serialize::writer::{to_writer, to_writer_pretty, BytesWriter}; use core::ptr::NonNull; use serde::ser::{Serialize, Serializer}; use std::io::Write; pub fn serialize( ptr: *mut pyo3_ffi::PyObject, default: Option>, opts: Opt, ) -> Result, String> { let mut buf = BytesWriter::default(); let obj = PyObjectSerializer::new(ptr, SerializerState::new(opts), default); let res = if opt_disabled!(opts, INDENT_2) { to_writer(&mut buf, &obj) } else { to_writer_pretty(&mut buf, &obj) }; match res { Ok(_) => { if opt_enabled!(opts, APPEND_NEWLINE) { let _ = buf.write(b"\n"); } Ok(buf.finish()) } Err(err) => { ffi!(_Py_Dealloc(buf.bytes_ptr().as_ptr())); Err(err.to_string()) } } } pub struct PyObjectSerializer { pub ptr: *mut pyo3_ffi::PyObject, pub state: SerializerState, pub default: Option>, } impl PyObjectSerializer { pub fn new( ptr: *mut pyo3_ffi::PyObject, state: SerializerState, default: Option>, ) -> Self { PyObjectSerializer { ptr: ptr, state: state, default: default, } } } impl Serialize for PyObjectSerializer { fn serialize(&self, serializer: S) -> Result where S: Serializer, { match pyobject_to_obtype(self.ptr, self.state.opts()) { ObType::Str => StrSerializer::new(self.ptr).serialize(serializer), ObType::StrSubclass => StrSubclassSerializer::new(self.ptr).serialize(serializer), ObType::Int => { if unlikely!(opt_enabled!(self.state.opts(), STRICT_INTEGER)) { Int53Serializer::new(self.ptr).serialize(serializer) } else { IntSerializer::new(self.ptr).serialize(serializer) } } ObType::None => NoneSerializer::new().serialize(serializer), ObType::Float => FloatSerializer::new(self.ptr).serialize(serializer), ObType::Bool => BoolSerializer::new(self.ptr).serialize(serializer), ObType::Datetime => DateTime::new(self.ptr, self.state.opts()).serialize(serializer), ObType::Date => Date::new(self.ptr).serialize(serializer), ObType::Time => Time::new(self.ptr, self.state.opts()).serialize(serializer), ObType::Uuid => UUID::new(self.ptr).serialize(serializer), ObType::Dict => { DictGenericSerializer::new(self.ptr, self.state, self.default).serialize(serializer) } ObType::List => { if ffi!(Py_SIZE(self.ptr)) == 0 { ZeroListSerializer::new().serialize(serializer) } else { ListTupleSerializer::from_list(self.ptr, self.state, self.default) .serialize(serializer) } } ObType::Tuple => { if ffi!(Py_SIZE(self.ptr)) == 0 { ZeroListSerializer::new().serialize(serializer) } else { ListTupleSerializer::from_tuple(self.ptr, self.state, self.default) .serialize(serializer) } } ObType::Dataclass => DataclassGenericSerializer::new(self).serialize(serializer), ObType::Enum => EnumSerializer::new(self).serialize(serializer), ObType::NumpyArray => NumpySerializer::new(self).serialize(serializer), ObType::NumpyScalar => { NumpyScalar::new(self.ptr, self.state.opts()).serialize(serializer) } ObType::Fragment => FragmentSerializer::new(self.ptr).serialize(serializer), ObType::Unknown => DefaultSerializer::new(self).serialize(serializer), } } } orjson-3.9.15/src/serialize/state.rs000066400000000000000000000027041456615046100174020ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::opt::*; const RECURSION_SHIFT: usize = 24; const RECURSION_MASK: u32 = 255 << RECURSION_SHIFT; const DEFAULT_SHIFT: usize = 16; const DEFAULT_MASK: u32 = 255 << DEFAULT_SHIFT; #[repr(transparent)] #[derive(Copy, Clone)] pub struct SerializerState { // recursion: u8, // default_calls: u8, // opts: u16, state: u32, } impl SerializerState { #[inline(always)] pub fn new(opts: Opt) -> Self { debug_assert!(opts < u16::MAX as u32); Self { state: opts } } #[inline(always)] pub fn opts(&self) -> u32 { self.state } #[inline(always)] pub fn recursion_limit(&self) -> bool { self.state & RECURSION_MASK == RECURSION_MASK } #[inline(always)] pub fn default_calls_limit(&self) -> bool { self.state & DEFAULT_MASK == DEFAULT_MASK } #[inline(always)] pub fn copy_for_recursive_call(&self) -> Self { let opt = self.state & !RECURSION_MASK; let recursion = (((self.state & RECURSION_MASK) >> RECURSION_SHIFT) + 1) << RECURSION_SHIFT; Self { state: opt | recursion, } } #[inline(always)] pub fn copy_for_default_call(&self) -> Self { let opt = self.state & !DEFAULT_MASK; let default_calls = (((self.state & DEFAULT_MASK) >> DEFAULT_SHIFT) + 1) << DEFAULT_SHIFT; Self { state: opt | default_calls, } } } orjson-3.9.15/src/serialize/writer/000077500000000000000000000000001456615046100172255ustar00rootroot00000000000000orjson-3.9.15/src/serialize/writer/byteswriter.rs000066400000000000000000000121671456615046100221650ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::c_char; use core::ptr::NonNull; use pyo3_ffi::{ PyBytesObject, PyBytes_FromStringAndSize, PyObject, PyVarObject, Py_ssize_t, _PyBytes_Resize, }; use std::io::Error; const BUFFER_LENGTH: usize = 1024; pub struct BytesWriter { cap: usize, len: usize, bytes: *mut PyBytesObject, } impl BytesWriter { pub fn default() -> Self { BytesWriter { cap: BUFFER_LENGTH, len: 0, bytes: unsafe { PyBytes_FromStringAndSize(core::ptr::null_mut(), BUFFER_LENGTH as isize) as *mut PyBytesObject }, } } pub fn bytes_ptr(&mut self) -> NonNull { unsafe { NonNull::new_unchecked(self.bytes as *mut PyObject) } } pub fn finish(&mut self) -> NonNull { unsafe { core::ptr::write(self.buffer_ptr(), 0); (*self.bytes.cast::()).ob_size = self.len as Py_ssize_t; self.resize(self.len); self.bytes_ptr() } } fn buffer_ptr(&self) -> *mut u8 { unsafe { core::mem::transmute::<*mut [c_char; 1], *mut u8>(core::ptr::addr_of_mut!( (*self.bytes).ob_sval )) .add(self.len) } } #[inline] pub fn resize(&mut self, len: usize) { self.cap = len; unsafe { _PyBytes_Resize( core::ptr::addr_of_mut!(self.bytes) as *mut *mut PyBytesObject as *mut *mut PyObject, len as isize, ); } } #[cold] #[inline(never)] fn grow(&mut self, len: usize) { let mut cap = self.cap; while len >= cap { if len < 262144 { cap *= 4; } else { cap *= 2; } } self.resize(cap); } } impl std::io::Write for BytesWriter { fn write(&mut self, buf: &[u8]) -> Result { let _ = self.write_all(buf); Ok(buf.len()) } fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> { let to_write = buf.len(); let end_length = self.len + to_write; if unlikely!(end_length >= self.cap) { self.grow(end_length); } unsafe { core::ptr::copy_nonoverlapping(buf.as_ptr(), self.buffer_ptr(), to_write); }; self.len = end_length; Ok(()) } fn flush(&mut self) -> Result<(), Error> { Ok(()) } } // hack based on saethlin's research and patch in https://github.com/serde-rs/json/issues/766 pub trait WriteExt: std::io::Write { #[inline] fn as_mut_buffer_ptr(&mut self) -> *mut u8 { core::ptr::null_mut() } #[inline] fn reserve(&mut self, len: usize) { let _ = len; } #[inline] fn set_written(&mut self, len: usize) { let _ = len; } #[inline] fn write_str(&mut self, val: &str) -> Result<(), Error> { let _ = val; Ok(()) } #[inline] unsafe fn write_reserved_fragment(&mut self, val: &[u8]) -> Result<(), Error> { let _ = val; Ok(()) } #[inline] unsafe fn write_reserved_punctuation(&mut self, val: u8) -> Result<(), Error> { let _ = val; Ok(()) } #[inline] unsafe fn write_reserved_indent(&mut self, len: usize) -> Result<(), Error> { let _ = len; Ok(()) } } impl WriteExt for &mut BytesWriter { #[inline(always)] fn as_mut_buffer_ptr(&mut self) -> *mut u8 { self.buffer_ptr() } #[inline(always)] fn reserve(&mut self, len: usize) { let end_length = self.len + len; if unlikely!(end_length >= self.cap) { self.grow(end_length); } } #[inline(always)] fn set_written(&mut self, len: usize) { self.len += len; } fn write_str(&mut self, val: &str) -> Result<(), Error> { let to_write = val.len(); let end_length = self.len + to_write + 2; if unlikely!(end_length >= self.cap) { self.grow(end_length); } unsafe { let ptr = self.buffer_ptr(); core::ptr::write(ptr, b'"'); core::ptr::copy_nonoverlapping(val.as_ptr(), ptr.add(1), to_write); core::ptr::write(ptr.add(to_write + 1), b'"'); }; self.len = end_length; Ok(()) } unsafe fn write_reserved_fragment(&mut self, val: &[u8]) -> Result<(), Error> { let to_write = val.len(); unsafe { core::ptr::copy_nonoverlapping(val.as_ptr(), self.buffer_ptr(), to_write); }; self.len += to_write; Ok(()) } #[inline(always)] unsafe fn write_reserved_punctuation(&mut self, val: u8) -> Result<(), Error> { unsafe { core::ptr::write(self.buffer_ptr(), val) }; self.len += 1; Ok(()) } #[inline(always)] unsafe fn write_reserved_indent(&mut self, len: usize) -> Result<(), Error> { unsafe { core::ptr::write_bytes(self.buffer_ptr(), b' ', len); }; self.len += len; Ok(()) } } orjson-3.9.15/src/serialize/writer/escape.rs000066400000000000000000000173231456615046100210410ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) // This is an adaptation of `src/value/ser.rs` from serde-json. use crate::serialize::writer::WriteExt; use std::io; pub enum CharEscape { /// An escaped quote `"` Quote, /// An escaped reverse solidus `\` ReverseSolidus, /// An escaped backspace character (usually escaped as `\b`) Backspace, /// An escaped form feed character (usually escaped as `\f`) FormFeed, /// An escaped line feed character (usually escaped as `\n`) LineFeed, /// An escaped carriage return character (usually escaped as `\r`) CarriageReturn, /// An escaped tab character (usually escaped as `\t`) Tab, /// An escaped ASCII plane control character (usually escaped as /// `\u00XX` where `XX` are two hex characters) AsciiControl(u8), } impl CharEscape { #[inline] fn from_escape_table(escape: u8, byte: u8) -> CharEscape { match escape { self::BB => CharEscape::Backspace, self::TT => CharEscape::Tab, self::NN => CharEscape::LineFeed, self::FF => CharEscape::FormFeed, self::RR => CharEscape::CarriageReturn, self::QU => CharEscape::Quote, self::BS => CharEscape::ReverseSolidus, self::UU => CharEscape::AsciiControl(byte), _ => unreachable!(), } } } #[inline] fn write_char_escape(writer: &mut W, char_escape: CharEscape) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { use CharEscape::*; let s = match char_escape { Quote => b"\\\"", ReverseSolidus => b"\\\\", Backspace => b"\\b", FormFeed => b"\\f", LineFeed => b"\\n", CarriageReturn => b"\\r", Tab => b"\\t", AsciiControl(byte) => { static HEX_DIGITS: [u8; 16] = *b"0123456789abcdef"; let bytes = &[ b'\\', b'u', b'0', b'0', HEX_DIGITS[(byte >> 4) as usize], HEX_DIGITS[(byte & 0xF) as usize], ]; return unsafe { writer.write_reserved_fragment(bytes) }; } }; unsafe { writer.write_reserved_fragment(s) } } #[inline(never)] pub fn format_escaped_str(writer: &mut W, value: &str) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { let len = value.len(); if len == 0 { reserve_minimum!(writer); return unsafe { writer.write_reserved_fragment(b"\"\"") }; } unsafe { let mut escapes: u8 = __; let mut idx = 0; let as_bytes = value.as_bytes(); while idx < len.saturating_sub(8) { escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 1) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 2) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 3) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 4) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 5) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 6) as usize); escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx + 7) as usize); if unlikely!(escapes != __) { return format_escaped_str_with_escapes(writer, as_bytes, idx); } idx += 8; } while idx < len { escapes |= *ESCAPE.get_unchecked(*as_bytes.get_unchecked(idx) as usize); if unlikely!(escapes != __) { return format_escaped_str_with_escapes(writer, as_bytes, idx); } idx += 1; } } writer.write_str(value) } fn format_escaped_str_with_escapes( writer: &mut W, value: &[u8], initial: usize, ) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { writer.reserve((value.len() * 8) + 2); unsafe { writer.write_reserved_punctuation(b'"').unwrap(); if initial > 0 { writer .write_reserved_fragment(value.get_unchecked(0..initial)) .unwrap(); } format_escaped_str_contents(writer, value.get_unchecked(initial..)).unwrap(); writer.write_reserved_punctuation(b'"').unwrap(); }; Ok(()) } fn format_escaped_str_contents(writer: &mut W, bytes: &[u8]) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { let len = bytes.len(); let mut start = 0; let mut idx = 0; let mut escape: u8; loop { if idx < len.saturating_sub(4) { escape = 0; unsafe { escape |= *ESCAPE.get_unchecked(*bytes.get_unchecked(idx) as usize); escape |= *ESCAPE.get_unchecked(*bytes.get_unchecked(idx + 1) as usize); escape |= *ESCAPE.get_unchecked(*bytes.get_unchecked(idx + 2) as usize); escape |= *ESCAPE.get_unchecked(*bytes.get_unchecked(idx + 3) as usize); } if escape == 0 { idx += 4; continue; } } let byte = unsafe { *bytes.get_unchecked(idx) }; escape = unsafe { *ESCAPE.get_unchecked(byte as usize) }; if escape == 0 { idx += 1; if idx == len { break; } else { continue; } } if start < idx { unsafe { writer .write_reserved_fragment(bytes.get_unchecked(start..idx)) .unwrap() }; } let char_escape = CharEscape::from_escape_table(escape, byte); write_char_escape(writer, char_escape)?; idx += 1; start = idx; if idx == len { break; } } if start != len { unsafe { writer .write_reserved_fragment(bytes.get_unchecked(start..len)) .unwrap() }; } Ok(()) } const BB: u8 = b'b'; // \x08 const TT: u8 = b't'; // \x09 const NN: u8 = b'n'; // \x0A const FF: u8 = b'f'; // \x0C const RR: u8 = b'r'; // \x0D const QU: u8 = b'"'; // \x22 const BS: u8 = b'\\'; // \x5C const UU: u8 = b'u'; // \x00...\x1F except the ones above const __: u8 = 0; // Lookup table of escape sequences. A value of b'x' at index i means that byte // i is escaped as "\x" in JSON. A value of 0 means that byte i is not escaped. const ESCAPE: [u8; 256] = [ // 1 2 3 4 5 6 7 8 9 A B C D E F UU, UU, UU, UU, UU, UU, UU, UU, BB, TT, NN, UU, FF, RR, UU, UU, // 0 UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, // 1 __, __, QU, __, __, __, __, __, __, __, __, __, __, __, __, __, // 2 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 3 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 4 __, __, __, __, __, __, __, __, __, __, __, __, BS, __, __, __, // 5 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 6 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 7 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 8 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 9 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // A __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // B __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // C __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // D __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // E __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // F ]; orjson-3.9.15/src/serialize/writer/formatter.rs000066400000000000000000000261551456615046100216070ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) // This is an adaptation of `src/value/ser.rs` from serde-json. use crate::serialize::writer::WriteExt; use std::io; pub trait Formatter { #[inline] fn write_null(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); writer.write_reserved_fragment(b"null") } } #[inline] fn write_bool(&mut self, writer: &mut W, value: bool) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { let s = if value { b"true" as &[u8] } else { b"false" as &[u8] }; reserve_minimum!(writer); unsafe { writer.write_reserved_fragment(s) } } #[inline] fn write_i8(&mut self, writer: &mut W, value: i8) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_i16(&mut self, writer: &mut W, value: i16) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_i32(&mut self, writer: &mut W, value: i32) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_i64(&mut self, writer: &mut W, value: i64) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_i128(&mut self, _writer: &mut W, _value: i128) -> io::Result<()> where W: ?Sized + io::Write, { unreachable!(); } #[inline] fn write_u8(&mut self, writer: &mut W, value: u8) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_u16(&mut self, writer: &mut W, value: u16) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_u32(&mut self, writer: &mut W, value: u32) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_u64(&mut self, writer: &mut W, value: u64) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = itoap::write_to_ptr(writer.as_mut_buffer_ptr(), value); writer.set_written(len); } Ok(()) } #[inline] fn write_u128(&mut self, _writer: &mut W, _value: u128) -> io::Result<()> where W: ?Sized + io::Write, { unreachable!(); } #[inline] fn write_f32(&mut self, writer: &mut W, value: f32) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = ryu::raw::format32(value, writer.as_mut_buffer_ptr()); writer.set_written(len); } Ok(()) } #[inline] fn write_f64(&mut self, writer: &mut W, value: f64) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { reserve_minimum!(writer); let len = ryu::raw::format64(value, writer.as_mut_buffer_ptr()); writer.set_written(len); } Ok(()) } fn write_number_str(&mut self, _writer: &mut W, _value: &str) -> io::Result<()> where W: ?Sized + io::Write, { unreachable!(); } #[inline] fn begin_string(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unreachable!(); } #[inline] fn end_string(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unreachable!(); } #[inline] fn write_string_fragment(&mut self, _writer: &mut W, _fragment: &str) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unreachable!(); } #[inline] fn begin_array(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b'[').unwrap() }; Ok(()) } #[inline] fn end_array(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b']').unwrap() }; Ok(()) } #[inline] fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { if !first { unsafe { reserve_minimum!(writer); writer.write_reserved_punctuation(b',').unwrap() } } Ok(()) } #[inline] fn end_array_value(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write, { Ok(()) } #[inline] fn begin_object(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b'{').unwrap(); } Ok(()) } #[inline] fn end_object(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b'}').unwrap(); } Ok(()) } #[inline] fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { if !first { unsafe { reserve_minimum!(writer); writer.write_reserved_punctuation(b',').unwrap(); } } Ok(()) } #[inline] fn end_object_key(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write, { Ok(()) } #[inline] fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b':') } } #[inline] fn end_object_value(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write, { Ok(()) } } pub struct CompactFormatter; impl Formatter for CompactFormatter {} pub struct PrettyFormatter { current_indent: usize, has_value: bool, } impl PrettyFormatter { pub const fn new() -> Self { PrettyFormatter { current_indent: 0, has_value: false, } } } impl Formatter for PrettyFormatter { #[inline] fn begin_array(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { self.current_indent += 1; self.has_value = false; reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b'[') } } #[inline] fn end_array(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { self.current_indent -= 1; let num_spaces = self.current_indent * 2; writer.reserve(num_spaces + 2); unsafe { if self.has_value { writer.write_reserved_punctuation(b'\n')?; writer.write_reserved_indent(num_spaces)?; } writer.write_reserved_punctuation(b']') } } #[inline] fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { let num_spaces = self.current_indent * 2; writer.reserve(num_spaces + 2); unsafe { writer.write_reserved_fragment(if first { b"\n" } else { b",\n" })?; writer.write_reserved_indent(num_spaces)?; }; Ok(()) } #[inline] fn end_array_value(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write, { self.has_value = true; Ok(()) } #[inline] fn begin_object(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { self.current_indent += 1; self.has_value = false; reserve_minimum!(writer); unsafe { writer.write_reserved_punctuation(b'{') } } #[inline] fn end_object(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { self.current_indent -= 1; let num_spaces = self.current_indent * 2; writer.reserve(num_spaces + 2); unsafe { if self.has_value { writer.write_reserved_punctuation(b'\n')?; writer.write_reserved_indent(num_spaces)?; } writer.write_reserved_punctuation(b'}') } } #[inline] fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { let num_spaces = self.current_indent * 2; writer.reserve(num_spaces + 2); unsafe { writer.write_reserved_fragment(if first { b"\n" } else { b",\n" })?; writer.write_reserved_indent(num_spaces)?; } Ok(()) } #[inline] fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { reserve_minimum!(writer); unsafe { writer.write_reserved_fragment(b": ").unwrap() }; Ok(()) } #[inline] fn end_object_value(&mut self, _writer: &mut W) -> io::Result<()> where W: ?Sized + io::Write, { self.has_value = true; Ok(()) } } orjson-3.9.15/src/serialize/writer/json.rs000066400000000000000000000347641456615046100205620ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) // This is an adaptation of `src/value/ser.rs` from serde-json. use crate::serialize::writer::formatter::{CompactFormatter, Formatter, PrettyFormatter}; use crate::serialize::writer::WriteExt; use serde::ser::{self, Impossible, Serialize}; use serde_json::error::{Error, Result}; use std::io; pub struct Serializer { writer: W, formatter: F, } impl Serializer where W: io::Write + WriteExt, { #[inline] pub fn new(writer: W) -> Self { Serializer::with_formatter(writer, CompactFormatter) } } impl Serializer where W: io::Write + WriteExt, { #[inline] pub fn pretty(writer: W) -> Self { Serializer::with_formatter(writer, PrettyFormatter::new()) } } impl Serializer where W: io::Write + WriteExt, F: Formatter, { #[inline] pub fn with_formatter(writer: W, formatter: F) -> Self { Serializer { writer, formatter } } #[inline] pub fn into_inner(self) -> W { self.writer } } impl<'a, W, F> ser::Serializer for &'a mut Serializer where W: io::Write + WriteExt, F: Formatter, { type Ok = (); type Error = Error; type SerializeSeq = Compound<'a, W, F>; type SerializeTuple = Impossible<(), Error>; type SerializeTupleStruct = Impossible<(), Error>; type SerializeTupleVariant = Impossible<(), Error>; type SerializeMap = Compound<'a, W, F>; type SerializeStruct = Impossible<(), Error>; type SerializeStructVariant = Impossible<(), Error>; #[inline] fn serialize_bool(self, value: bool) -> Result<()> { self.formatter .write_bool(&mut self.writer, value) .map_err(Error::io) } #[cold] fn serialize_i8(self, value: i8) -> Result<()> { self.formatter .write_i8(&mut self.writer, value) .map_err(Error::io) } #[cold] fn serialize_i16(self, value: i16) -> Result<()> { self.formatter .write_i16(&mut self.writer, value) .map_err(Error::io) } #[inline] fn serialize_i32(self, value: i32) -> Result<()> { self.formatter .write_i32(&mut self.writer, value) .map_err(Error::io) } #[inline] fn serialize_i64(self, value: i64) -> Result<()> { self.formatter .write_i64(&mut self.writer, value) .map_err(Error::io) } fn serialize_i128(self, _value: i128) -> Result<()> { unreachable!(); } #[cold] fn serialize_u8(self, value: u8) -> Result<()> { self.formatter .write_u8(&mut self.writer, value) .map_err(Error::io) } #[cold] fn serialize_u16(self, value: u16) -> Result<()> { self.formatter .write_u16(&mut self.writer, value) .map_err(Error::io) } #[inline] fn serialize_u32(self, value: u32) -> Result<()> { self.formatter .write_u32(&mut self.writer, value) .map_err(Error::io) } #[inline] fn serialize_u64(self, value: u64) -> Result<()> { self.formatter .write_u64(&mut self.writer, value) .map_err(Error::io) } fn serialize_u128(self, _value: u128) -> Result<()> { unreachable!(); } #[inline] fn serialize_f32(self, value: f32) -> Result<()> { if unlikely!(value.is_infinite() || value.is_nan()) { self.serialize_unit() } else { self.formatter .write_f32(&mut self.writer, value) .map_err(Error::io) } } #[inline] fn serialize_f64(self, value: f64) -> Result<()> { if unlikely!(value.is_infinite() || value.is_nan()) { self.serialize_unit() } else { self.formatter .write_f64(&mut self.writer, value) .map_err(Error::io) } } fn serialize_char(self, _value: char) -> Result<()> { unreachable!(); } #[inline] fn serialize_str(self, value: &str) -> Result<()> { format_escaped_str(&mut self.writer, value).map_err(Error::io) } fn serialize_bytes(self, value: &[u8]) -> Result<()> { self.writer.reserve(value.len()); unsafe { self.writer.write_reserved_fragment(value).unwrap() }; Ok(()) } #[inline] fn serialize_unit(self) -> Result<()> { self.formatter .write_null(&mut self.writer) .map_err(Error::io) } fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { unreachable!(); } fn serialize_unit_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, ) -> Result<()> { unreachable!(); } fn serialize_newtype_struct(self, _name: &'static str, _value: &T) -> Result<()> where T: ?Sized + Serialize, { unreachable!(); } fn serialize_newtype_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _value: &T, ) -> Result<()> where T: ?Sized + Serialize, { unreachable!(); } #[inline] fn serialize_none(self) -> Result<()> { self.serialize_unit() } #[inline] fn serialize_some(self, value: &T) -> Result<()> where T: ?Sized + Serialize, { value.serialize(self) } #[inline(always)] fn serialize_seq(self, _len: Option) -> Result { self.formatter .begin_array(&mut self.writer) .map_err(Error::io)?; Ok(Compound { ser: self, state: State::First, }) } fn serialize_tuple(self, _len: usize) -> Result { unreachable!(); } fn serialize_tuple_struct( self, _name: &'static str, _len: usize, ) -> Result { unreachable!(); } fn serialize_tuple_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize, ) -> Result { unreachable!(); } #[inline(always)] fn serialize_map(self, _len: Option) -> Result { self.formatter .begin_object(&mut self.writer) .map_err(Error::io)?; Ok(Compound { ser: self, state: State::First, }) } fn serialize_struct(self, _name: &'static str, _len: usize) -> Result { unreachable!(); } fn serialize_struct_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize, ) -> Result { unreachable!(); } } #[derive(Eq, PartialEq)] pub enum State { First, Rest, } pub struct Compound<'a, W: 'a, F: 'a> { ser: &'a mut Serializer, state: State, } impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> where W: io::Write + WriteExt, F: Formatter, { type Ok = (); type Error = Error; #[inline] fn serialize_element(&mut self, value: &T) -> Result<()> where T: ?Sized + Serialize, { self.ser .formatter .begin_array_value(&mut self.ser.writer, self.state == State::First) .map_err(Error::io)?; self.state = State::Rest; value.serialize(&mut *self.ser)?; self.ser .formatter .end_array_value(&mut self.ser.writer) .map_err(Error::io) } #[inline] fn end(self) -> Result<()> { self.ser .formatter .end_array(&mut self.ser.writer) .map_err(Error::io) } } impl<'a, W, F> ser::SerializeMap for Compound<'a, W, F> where W: io::Write + WriteExt, F: Formatter, { type Ok = (); type Error = Error; fn serialize_entry(&mut self, _key: &K, _value: &V) -> Result<()> where K: ?Sized + Serialize, V: ?Sized + Serialize, { unreachable!() } #[inline] fn serialize_key(&mut self, key: &T) -> Result<()> where T: ?Sized + Serialize, { self.ser .formatter .begin_object_key(&mut self.ser.writer, self.state == State::First) .map_err(Error::io)?; self.state = State::Rest; key.serialize(MapKeySerializer { ser: self.ser })?; self.ser .formatter .end_object_key(&mut self.ser.writer) .map_err(Error::io) } #[inline] fn serialize_value(&mut self, value: &T) -> Result<()> where T: ?Sized + Serialize, { self.ser .formatter .begin_object_value(&mut self.ser.writer) .map_err(Error::io)?; value.serialize(&mut *self.ser)?; self.ser .formatter .end_object_value(&mut self.ser.writer) .map_err(Error::io) } #[inline] fn end(self) -> Result<()> { self.ser .formatter .end_object(&mut self.ser.writer) .map_err(Error::io) } } #[repr(transparent)] struct MapKeySerializer<'a, W: 'a, F: 'a> { ser: &'a mut Serializer, } impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> where W: io::Write + WriteExt, F: Formatter, { type Ok = (); type Error = Error; type SerializeSeq = Impossible<(), Error>; type SerializeTuple = Impossible<(), Error>; type SerializeTupleStruct = Impossible<(), Error>; type SerializeTupleVariant = Impossible<(), Error>; type SerializeMap = Impossible<(), Error>; type SerializeStruct = Impossible<(), Error>; type SerializeStructVariant = Impossible<(), Error>; #[inline] fn serialize_str(self, value: &str) -> Result<()> { self.ser.serialize_str(value) } fn serialize_unit_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, ) -> Result<()> { unreachable!(); } fn serialize_newtype_struct(self, _name: &'static str, _value: &T) -> Result<()> where T: ?Sized + Serialize, { unreachable!(); } fn serialize_bool(self, _value: bool) -> Result<()> { unreachable!(); } fn serialize_i8(self, _value: i8) -> Result<()> { unreachable!(); } fn serialize_i16(self, _value: i16) -> Result<()> { unreachable!(); } fn serialize_i32(self, _value: i32) -> Result<()> { unreachable!(); } fn serialize_i64(self, _value: i64) -> Result<()> { unreachable!(); } fn serialize_i128(self, _value: i128) -> Result<()> { unreachable!(); } fn serialize_u8(self, _value: u8) -> Result<()> { unreachable!(); } fn serialize_u16(self, _value: u16) -> Result<()> { unreachable!(); } fn serialize_u32(self, _value: u32) -> Result<()> { unreachable!(); } fn serialize_u64(self, _value: u64) -> Result<()> { unreachable!(); } fn serialize_u128(self, _value: u128) -> Result<()> { unreachable!(); } fn serialize_f32(self, _value: f32) -> Result<()> { unreachable!(); } fn serialize_f64(self, _value: f64) -> Result<()> { unreachable!(); } fn serialize_char(self, _value: char) -> Result<()> { unreachable!(); } fn serialize_bytes(self, _value: &[u8]) -> Result<()> { unreachable!(); } fn serialize_unit(self) -> Result<()> { unreachable!(); } fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { unreachable!(); } fn serialize_newtype_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _value: &T, ) -> Result<()> where T: ?Sized + Serialize, { unreachable!(); } fn serialize_none(self) -> Result<()> { unreachable!(); } fn serialize_some(self, _value: &T) -> Result<()> where T: ?Sized + Serialize, { unreachable!(); } fn serialize_seq(self, _len: Option) -> Result { unreachable!(); } fn serialize_tuple(self, _len: usize) -> Result { unreachable!(); } fn serialize_tuple_struct( self, _name: &'static str, _len: usize, ) -> Result { unreachable!(); } fn serialize_tuple_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize, ) -> Result { unreachable!(); } fn serialize_map(self, _len: Option) -> Result { unreachable!(); } fn serialize_struct(self, _name: &'static str, _len: usize) -> Result { unreachable!(); } fn serialize_struct_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize, ) -> Result { unreachable!(); } } #[cfg(feature = "unstable-simd")] #[inline(always)] fn format_escaped_str(writer: &mut W, value: &str) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { unsafe { let num_reserved_bytes = value.len() * 8 + 32; writer.reserve(num_reserved_bytes); let written = crate::serialize::writer::simd::format_escaped_str_impl_128( writer.as_mut_buffer_ptr(), value.as_bytes().as_ptr(), value.len(), ); writer.set_written(written); } Ok(()) } #[cfg(not(feature = "unstable-simd"))] #[inline(always)] fn format_escaped_str(writer: &mut W, value: &str) -> io::Result<()> where W: ?Sized + io::Write + WriteExt, { crate::serialize::writer::escape::format_escaped_str(writer, value) } #[inline] pub fn to_writer(writer: W, value: &T) -> Result<()> where W: io::Write + WriteExt, T: ?Sized + Serialize, { let mut ser = Serializer::new(writer); value.serialize(&mut ser) } #[inline] pub fn to_writer_pretty(writer: W, value: &T) -> Result<()> where W: io::Write + WriteExt, T: ?Sized + Serialize, { let mut ser = Serializer::pretty(writer); value.serialize(&mut ser) } orjson-3.9.15/src/serialize/writer/mod.rs000066400000000000000000000004151456615046100203520ustar00rootroot00000000000000// SPDX-License-Identifier: Apache-2.0 mod byteswriter; #[cfg(not(feature = "unstable-simd"))] mod escape; mod formatter; mod json; #[cfg(feature = "unstable-simd")] mod simd; pub use byteswriter::{BytesWriter, WriteExt}; pub use json::{to_writer, to_writer_pretty}; orjson-3.9.15/src/serialize/writer/simd.rs000066400000000000000000000127751456615046100205430ustar00rootroot00000000000000// SPDX-License-Identifier: Apache-2.0 // Copyright 2023-2024 liuq19, ijl // adapted from sonic-rs' src/util/string.rs use core::simd::cmp::{SimdPartialEq, SimdPartialOrd}; macro_rules! impl_escape_unchecked { ($src:expr, $dst:expr, $nb:expr, $omask:expr, $cn:expr, $v:expr, $rotate:expr) => { $nb -= $cn; if $rotate == true { for _ in 0..$cn { $v = $v.rotate_elements_left::<1>(); } } $dst = $dst.add($cn); $src = $src.add($cn); $omask >>= $cn; loop { $nb -= 1; if $rotate == true { $v = $v.rotate_elements_left::<1>(); } $omask = $omask >> 1; if *($src) == b'"' { core::ptr::copy_nonoverlapping(b"\\\"".as_ptr(), $dst, 2); $dst = $dst.add(2); } else if *($src) == b'\\' { core::ptr::copy_nonoverlapping(b"\\\\".as_ptr(), $dst, 2); $dst = $dst.add(2); } else { $dst = write_unusual_escape($src, $dst); }; $src = $src.add(1); if likely!($omask & 1 != 1) { break; } } }; } macro_rules! impl_format_simd { ($odptr:expr, $value_ptr:expr, $value_len:expr) => { let mut dptr = $odptr; let dstart = $odptr; let mut sptr = $value_ptr; let mut nb: usize = $value_len; let blash = StrVector::from_array([b'\\'; STRIDE]); let quote = StrVector::from_array([b'"'; STRIDE]); let x20 = StrVector::from_array([32; STRIDE]); unsafe { *dptr = b'"'; dptr = dptr.add(1); { const ROTATE: bool = false; while nb >= STRIDE { let mut v = StrVector::from_slice(core::slice::from_raw_parts(sptr, STRIDE)); let mut mask = (v.simd_eq(blash) | v.simd_eq(quote) | v.simd_lt(x20)).to_bitmask() as u32; v.copy_to_slice(core::slice::from_raw_parts_mut(dptr, STRIDE)); if likely!(mask == 0) { nb -= STRIDE; dptr = dptr.add(STRIDE); sptr = sptr.add(STRIDE); } else { let cn = mask.trailing_zeros() as usize; impl_escape_unchecked!(sptr, dptr, nb, mask, cn, v, ROTATE); } } } { const ROTATE: bool = true; let mut v = StrVector::default(); { let vec_ptr = v.as_mut_array().as_mut_ptr(); for idx in 0..nb { core::ptr::write(vec_ptr.add(idx), *sptr.add(idx)); } } let mut mask = (v.simd_eq(blash) | v.simd_eq(quote) | v.simd_lt(x20)).to_bitmask() as u32 & (STRIDE_SATURATION >> (32 - STRIDE - nb)); while nb > 0 { v.copy_to_slice(core::slice::from_raw_parts_mut(dptr, STRIDE)); if likely!(mask == 0) { dptr = dptr.add(nb); break; } else { let cn = mask.trailing_zeros() as usize; impl_escape_unchecked!(sptr, dptr, nb, mask, cn, v, ROTATE); } } } *dptr = b'"'; dptr = dptr.add(1); } return dptr as usize - dstart as usize; }; } #[cold] #[inline(never)] fn write_unusual_escape(sptr: *const u8, dptr: *mut u8) -> *mut u8 { unsafe { debug_assert!(*sptr < 32); let replacement = match *(sptr) { 0 => (*b"\\u0000\0\0", 6), 1 => (*b"\\u0001\0\0", 6), 2 => (*b"\\u0002\0\0", 6), 3 => (*b"\\u0003\0\0", 6), 4 => (*b"\\u0004\0\0", 6), 5 => (*b"\\u0005\0\0", 6), 6 => (*b"\\u0006\0\0", 6), 7 => (*b"\\u0007\0\0", 6), 8 => (*b"\\b\0\0\0\0\0\0", 2), 9 => (*b"\\t\0\0\0\0\0\0", 2), 10 => (*b"\\n\0\0\0\0\0\0", 2), 11 => (*b"\\u000b\0\0", 6), 12 => (*b"\\f\0\0\0\0\0\0", 2), 13 => (*b"\\r\0\0\0\0\0\0", 2), 14 => (*b"\\u000e\0\0", 6), 15 => (*b"\\u000f\0\0", 6), 16 => (*b"\\u0010\0\0", 6), 17 => (*b"\\u0011\0\0", 6), 18 => (*b"\\u0012\0\0", 6), 19 => (*b"\\u0013\0\0", 6), 20 => (*b"\\u0014\0\0", 6), 21 => (*b"\\u0015\0\0", 6), 22 => (*b"\\u0016\0\0", 6), 23 => (*b"\\u0017\0\0", 6), 24 => (*b"\\u0018\0\0", 6), 25 => (*b"\\u0019\0\0", 6), 26 => (*b"\\u001a\0\0", 6), 27 => (*b"\\u001b\0\0", 6), 28 => (*b"\\u001c\0\0", 6), 29 => (*b"\\u001d\0\0", 6), 30 => (*b"\\u001e\0\0", 6), 31 => (*b"\\u001f\0\0", 6), _ => unreachable!(), }; core::ptr::copy_nonoverlapping(replacement.0.as_ptr(), dptr, 8); dptr.add(replacement.1 as usize) } } #[inline(never)] pub unsafe fn format_escaped_str_impl_128( odptr: *mut u8, value_ptr: *const u8, value_len: usize, ) -> usize { const STRIDE: usize = 16; const STRIDE_SATURATION: u32 = u16::MAX as u32; type StrVector = core::simd::u8x16; impl_format_simd!(odptr, value_ptr, value_len); } orjson-3.9.15/src/str/000077500000000000000000000000001456615046100145325ustar00rootroot00000000000000orjson-3.9.15/src/str/check.rs000066400000000000000000000020351456615046100161550ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) const STRIDE_SIZE: usize = 8; pub fn is_four_byte(buf: &str) -> bool { let as_bytes = buf.as_bytes(); let len = as_bytes.len(); unsafe { let mut idx = 0; while idx < len.saturating_sub(STRIDE_SIZE) { let mut val: bool = false; val |= *as_bytes.get_unchecked(idx) > 239; val |= *as_bytes.get_unchecked(idx + 1) > 239; val |= *as_bytes.get_unchecked(idx + 2) > 239; val |= *as_bytes.get_unchecked(idx + 3) > 239; val |= *as_bytes.get_unchecked(idx + 4) > 239; val |= *as_bytes.get_unchecked(idx + 5) > 239; val |= *as_bytes.get_unchecked(idx + 6) > 239; val |= *as_bytes.get_unchecked(idx + 7) > 239; idx += STRIDE_SIZE; if val { return true; } } let mut ret = false; while idx < len { ret |= *as_bytes.get_unchecked(idx) > 239; idx += 1; } ret } } orjson-3.9.15/src/str/create.rs000066400000000000000000000054231456615046100163470ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::str::is_four_byte; use crate::typeref::EMPTY_UNICODE; use pyo3_ffi::*; enum PyUnicodeKind { Ascii, OneByte, TwoByte, FourByte, } fn find_str_kind(buf: &str, num_chars: usize) -> PyUnicodeKind { if buf.len() == num_chars { PyUnicodeKind::Ascii } else if is_four_byte(buf) { PyUnicodeKind::FourByte } else if encoding_rs::mem::is_str_latin1(buf) { PyUnicodeKind::OneByte } else { PyUnicodeKind::TwoByte } } pub fn unicode_from_str(buf: &str) -> *mut pyo3_ffi::PyObject { if buf.is_empty() { use_immortal!(EMPTY_UNICODE) } else { let num_chars = bytecount::num_chars(buf.as_bytes()); match find_str_kind(buf, num_chars) { PyUnicodeKind::Ascii => pyunicode_ascii(buf), PyUnicodeKind::OneByte => pyunicode_onebyte(buf, num_chars), PyUnicodeKind::TwoByte => pyunicode_twobyte(buf, num_chars), PyUnicodeKind::FourByte => pyunicode_fourbyte(buf, num_chars), } } } pub fn pyunicode_ascii(buf: &str) -> *mut pyo3_ffi::PyObject { unsafe { let ptr = ffi!(PyUnicode_New(buf.len() as isize, 127)); let data_ptr = ptr.cast::().offset(1) as *mut u8; core::ptr::copy_nonoverlapping(buf.as_ptr(), data_ptr, buf.len()); core::ptr::write(data_ptr.add(buf.len()), 0); ptr } } #[cold] #[inline(never)] pub fn pyunicode_onebyte(buf: &str, num_chars: usize) -> *mut pyo3_ffi::PyObject { unsafe { let ptr = ffi!(PyUnicode_New(num_chars as isize, 255)); let mut data_ptr = ptr.cast::().offset(1) as *mut u8; for each in buf.chars().fuse() { core::ptr::write(data_ptr, each as u8); data_ptr = data_ptr.offset(1); } core::ptr::write(data_ptr, 0); ptr } } pub fn pyunicode_twobyte(buf: &str, num_chars: usize) -> *mut pyo3_ffi::PyObject { unsafe { let ptr = ffi!(PyUnicode_New(num_chars as isize, 65535)); let mut data_ptr = ptr.cast::().offset(1) as *mut u16; for each in buf.chars().fuse() { core::ptr::write(data_ptr, each as u16); data_ptr = data_ptr.offset(1); } core::ptr::write(data_ptr, 0); ptr } } pub fn pyunicode_fourbyte(buf: &str, num_chars: usize) -> *mut pyo3_ffi::PyObject { unsafe { let ptr = ffi!(PyUnicode_New(num_chars as isize, 1114111)); let mut data_ptr = ptr.cast::().offset(1) as *mut u32; for each in buf.chars().fuse() { core::ptr::write(data_ptr, each as u32); data_ptr = data_ptr.offset(1); } core::ptr::write(data_ptr, 0); ptr } } orjson-3.9.15/src/str/ffi.rs000066400000000000000000000036101456615046100156440ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use core::ffi::c_void; use pyo3_ffi::*; // see unicodeobject.h for documentation #[inline] pub fn hash_str(op: *mut PyObject) -> Py_hash_t { unsafe { let data_ptr: *mut c_void = if (*op.cast::()).compact() == 1 && (*op.cast::()).ascii() == 1 { (op as *mut PyASCIIObject).offset(1) as *mut c_void } else { (op as *mut PyCompactUnicodeObject).offset(1) as *mut c_void }; let num_bytes = (*(op as *mut PyASCIIObject)).length * ((*(op as *mut PyASCIIObject)).kind()) as isize; let hash = pyo3_ffi::_Py_HashBytes(data_ptr, num_bytes); (*op.cast::()).hash = hash; hash } } #[inline(never)] pub fn unicode_to_str_via_ffi(op: *mut PyObject) -> Option<&'static str> { let mut str_size: pyo3_ffi::Py_ssize_t = 0; let ptr = ffi!(PyUnicode_AsUTF8AndSize(op, &mut str_size)) as *const u8; if unlikely!(ptr.is_null()) { None } else { Some(str_from_slice!(ptr, str_size as usize)) } } #[inline] pub fn unicode_to_str(op: *mut PyObject) -> Option<&'static str> { unsafe { if unlikely!((*op.cast::()).compact() == 0) { unicode_to_str_via_ffi(op) } else if (*op.cast::()).ascii() == 1 { let ptr = op.cast::().offset(1) as *const u8; let len = (*op.cast::()).length as usize; Some(str_from_slice!(ptr, len)) } else if (*op.cast::()).utf8_length != 0 { let ptr = (*op.cast::()).utf8 as *const u8; let len = (*op.cast::()).utf8_length as usize; Some(str_from_slice!(ptr, len)) } else { unicode_to_str_via_ffi(op) } } } orjson-3.9.15/src/str/mod.rs000066400000000000000000000002071456615046100156560ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) mod check; mod create; mod ffi; pub use check::*; pub use create::*; pub use ffi::*; orjson-3.9.15/src/typeref.rs000066400000000000000000000315671456615046100157620ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::ffi::orjson_fragmenttype_new; use core::ffi::c_char; #[cfg(feature = "yyjson")] use core::ffi::c_void; #[cfg(feature = "yyjson")] use core::mem::MaybeUninit; use core::ptr::{null_mut, NonNull}; use once_cell::race::{OnceBool, OnceBox}; use pyo3_ffi::*; #[cfg(feature = "yyjson")] use std::cell::UnsafeCell; pub struct NumpyTypes { pub array: *mut PyTypeObject, pub float64: *mut PyTypeObject, pub float32: *mut PyTypeObject, pub int64: *mut PyTypeObject, pub int32: *mut PyTypeObject, pub int16: *mut PyTypeObject, pub int8: *mut PyTypeObject, pub uint64: *mut PyTypeObject, pub uint32: *mut PyTypeObject, pub uint16: *mut PyTypeObject, pub uint8: *mut PyTypeObject, pub bool_: *mut PyTypeObject, pub datetime64: *mut PyTypeObject, } pub static mut DEFAULT: *mut PyObject = null_mut(); pub static mut OPTION: *mut PyObject = null_mut(); pub static mut NONE: *mut PyObject = null_mut(); pub static mut TRUE: *mut PyObject = null_mut(); pub static mut FALSE: *mut PyObject = null_mut(); pub static mut EMPTY_UNICODE: *mut PyObject = null_mut(); pub static mut BYTES_TYPE: *mut PyTypeObject = null_mut(); pub static mut BYTEARRAY_TYPE: *mut PyTypeObject = null_mut(); pub static mut MEMORYVIEW_TYPE: *mut PyTypeObject = null_mut(); pub static mut STR_TYPE: *mut PyTypeObject = null_mut(); pub static mut INT_TYPE: *mut PyTypeObject = null_mut(); pub static mut BOOL_TYPE: *mut PyTypeObject = null_mut(); pub static mut NONE_TYPE: *mut PyTypeObject = null_mut(); pub static mut FLOAT_TYPE: *mut PyTypeObject = null_mut(); pub static mut LIST_TYPE: *mut PyTypeObject = null_mut(); pub static mut DICT_TYPE: *mut PyTypeObject = null_mut(); pub static mut DATETIME_TYPE: *mut PyTypeObject = null_mut(); pub static mut DATE_TYPE: *mut PyTypeObject = null_mut(); pub static mut TIME_TYPE: *mut PyTypeObject = null_mut(); pub static mut TUPLE_TYPE: *mut PyTypeObject = null_mut(); pub static mut UUID_TYPE: *mut PyTypeObject = null_mut(); pub static mut ENUM_TYPE: *mut PyTypeObject = null_mut(); pub static mut FIELD_TYPE: *mut PyTypeObject = null_mut(); pub static mut FRAGMENT_TYPE: *mut PyTypeObject = null_mut(); pub static mut NUMPY_TYPES: OnceBox>> = OnceBox::new(); #[cfg(Py_3_9)] pub static mut ZONEINFO_TYPE: *mut PyTypeObject = null_mut(); pub static mut UTCOFFSET_METHOD_STR: *mut PyObject = null_mut(); pub static mut NORMALIZE_METHOD_STR: *mut PyObject = null_mut(); pub static mut CONVERT_METHOD_STR: *mut PyObject = null_mut(); pub static mut DST_STR: *mut PyObject = null_mut(); pub static mut DICT_STR: *mut PyObject = null_mut(); pub static mut DATACLASS_FIELDS_STR: *mut PyObject = null_mut(); pub static mut SLOTS_STR: *mut PyObject = null_mut(); pub static mut FIELD_TYPE_STR: *mut PyObject = null_mut(); pub static mut ARRAY_STRUCT_STR: *mut PyObject = null_mut(); pub static mut DTYPE_STR: *mut PyObject = null_mut(); pub static mut DESCR_STR: *mut PyObject = null_mut(); pub static mut VALUE_STR: *mut PyObject = null_mut(); pub static mut INT_ATTR_STR: *mut PyObject = null_mut(); #[cfg(feature = "yyjson")] pub const YYJSON_BUFFER_SIZE: usize = 1024 * 1024 * 8; #[cfg(feature = "yyjson")] #[repr(align(64))] struct YYJSONBuffer(UnsafeCell>); #[cfg(feature = "yyjson")] pub struct YYJSONAlloc { pub alloc: crate::ffi::yyjson::yyjson_alc, _buffer: Box, } #[cfg(feature = "yyjson")] pub static mut YYJSON_ALLOC: OnceBox = OnceBox::new(); #[cfg(feature = "yyjson")] pub fn yyjson_init() -> Box { // Using unsafe to ensure allocation happens on the heap without going through the stack // so we don't stack overflow in debug mode. Once rust-lang/rust#63291 is stable (Box::new_uninit) // we can use that instead. let layout = std::alloc::Layout::new::(); let buffer = unsafe { Box::from_raw(std::alloc::alloc(layout).cast::()) }; let mut alloc = crate::ffi::yyjson::yyjson_alc { malloc: None, realloc: None, free: None, ctx: null_mut(), }; unsafe { crate::ffi::yyjson::yyjson_alc_pool_init( &mut alloc, buffer.0.get().cast::(), YYJSON_BUFFER_SIZE, ); } Box::new(YYJSONAlloc { alloc, _buffer: buffer, }) } #[allow(non_upper_case_globals)] pub static mut JsonEncodeError: *mut PyObject = null_mut(); #[allow(non_upper_case_globals)] pub static mut JsonDecodeError: *mut PyObject = null_mut(); static INIT: OnceBool = OnceBool::new(); #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub fn init_typerefs() { INIT.get_or_init(_init_typerefs_impl); } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] fn _init_typerefs_impl() -> bool { unsafe { debug_assert!(crate::opt::MAX_OPT < u16::MAX as i32); assert!(crate::deserialize::KEY_MAP .set(crate::deserialize::KeyMap::default()) .is_ok()); FRAGMENT_TYPE = orjson_fragmenttype_new(); PyDateTime_IMPORT(); NONE = Py_None(); TRUE = Py_True(); FALSE = Py_False(); EMPTY_UNICODE = PyUnicode_New(0, 255); STR_TYPE = (*EMPTY_UNICODE).ob_type; BYTES_TYPE = (*PyBytes_FromStringAndSize("".as_ptr() as *const c_char, 0)).ob_type; { let bytearray = PyByteArray_FromStringAndSize("".as_ptr() as *const c_char, 0); BYTEARRAY_TYPE = (*bytearray).ob_type; let memoryview = PyMemoryView_FromObject(bytearray); MEMORYVIEW_TYPE = (*memoryview).ob_type; Py_DECREF(memoryview); Py_DECREF(bytearray); } DICT_TYPE = (*PyDict_New()).ob_type; LIST_TYPE = (*PyList_New(0)).ob_type; TUPLE_TYPE = (*PyTuple_New(0)).ob_type; NONE_TYPE = (*NONE).ob_type; BOOL_TYPE = (*TRUE).ob_type; INT_TYPE = (*PyLong_FromLongLong(0)).ob_type; FLOAT_TYPE = (*PyFloat_FromDouble(0.0)).ob_type; DATETIME_TYPE = look_up_datetime_type(); DATE_TYPE = look_up_date_type(); TIME_TYPE = look_up_time_type(); UUID_TYPE = look_up_uuid_type(); ENUM_TYPE = look_up_enum_type(); FIELD_TYPE = look_up_field_type(); #[cfg(Py_3_9)] { ZONEINFO_TYPE = look_up_zoneinfo_type(); } INT_ATTR_STR = PyUnicode_InternFromString("int\0".as_ptr() as *const c_char); UTCOFFSET_METHOD_STR = PyUnicode_InternFromString("utcoffset\0".as_ptr() as *const c_char); NORMALIZE_METHOD_STR = PyUnicode_InternFromString("normalize\0".as_ptr() as *const c_char); CONVERT_METHOD_STR = PyUnicode_InternFromString("convert\0".as_ptr() as *const c_char); DST_STR = PyUnicode_InternFromString("dst\0".as_ptr() as *const c_char); DICT_STR = PyUnicode_InternFromString("__dict__\0".as_ptr() as *const c_char); DATACLASS_FIELDS_STR = PyUnicode_InternFromString("__dataclass_fields__\0".as_ptr() as *const c_char); SLOTS_STR = PyUnicode_InternFromString("__slots__\0".as_ptr() as *const c_char); FIELD_TYPE_STR = PyUnicode_InternFromString("_field_type\0".as_ptr() as *const c_char); ARRAY_STRUCT_STR = PyUnicode_InternFromString("__array_struct__\0".as_ptr() as *const c_char); DTYPE_STR = PyUnicode_InternFromString("dtype\0".as_ptr() as *const c_char); DESCR_STR = PyUnicode_InternFromString("descr\0".as_ptr() as *const c_char); VALUE_STR = PyUnicode_InternFromString("value\0".as_ptr() as *const c_char); DEFAULT = PyUnicode_InternFromString("default\0".as_ptr() as *const c_char); OPTION = PyUnicode_InternFromString("option\0".as_ptr() as *const c_char); JsonEncodeError = pyo3_ffi::PyExc_TypeError; Py_INCREF(JsonEncodeError); JsonDecodeError = look_up_json_exc(); }; true } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_json_exc() -> *mut PyObject { let module = PyImport_ImportModule("json\0".as_ptr() as *const c_char); let module_dict = PyObject_GenericGetDict(module, null_mut()); let ptr = PyMapping_GetItemString(module_dict, "JSONDecodeError\0".as_ptr() as *const c_char); let res = pyo3_ffi::PyErr_NewException( "orjson.JSONDecodeError\0".as_ptr() as *const c_char, ptr, null_mut(), ); Py_DECREF(ptr); Py_DECREF(module_dict); Py_DECREF(module); Py_INCREF(res); res } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_numpy_type(numpy_module_dict: *mut PyObject, np_type: &str) -> *mut PyTypeObject { let ptr = PyMapping_GetItemString(numpy_module_dict, np_type.as_ptr() as *const c_char); Py_XDECREF(ptr); ptr as *mut PyTypeObject } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] pub fn load_numpy_types() -> Box>> { unsafe { let numpy = PyImport_ImportModule("numpy\0".as_ptr() as *const c_char); if numpy.is_null() { PyErr_Clear(); return Box::new(None); } let numpy_module_dict = PyObject_GenericGetDict(numpy, null_mut()); let types = Box::new(NumpyTypes { array: look_up_numpy_type(numpy_module_dict, "ndarray\0"), float32: look_up_numpy_type(numpy_module_dict, "float32\0"), float64: look_up_numpy_type(numpy_module_dict, "float64\0"), int8: look_up_numpy_type(numpy_module_dict, "int8\0"), int16: look_up_numpy_type(numpy_module_dict, "int16\0"), int32: look_up_numpy_type(numpy_module_dict, "int32\0"), int64: look_up_numpy_type(numpy_module_dict, "int64\0"), uint16: look_up_numpy_type(numpy_module_dict, "uint16\0"), uint32: look_up_numpy_type(numpy_module_dict, "uint32\0"), uint64: look_up_numpy_type(numpy_module_dict, "uint64\0"), uint8: look_up_numpy_type(numpy_module_dict, "uint8\0"), bool_: look_up_numpy_type(numpy_module_dict, "bool_\0"), datetime64: look_up_numpy_type(numpy_module_dict, "datetime64\0"), }); Py_XDECREF(numpy_module_dict); Py_XDECREF(numpy); Box::new(Some(nonnull!(Box::::into_raw(types)))) } } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_field_type() -> *mut PyTypeObject { let module = PyImport_ImportModule("dataclasses\0".as_ptr() as *const c_char); let module_dict = PyObject_GenericGetDict(module, null_mut()); let ptr = PyMapping_GetItemString(module_dict, "_FIELD\0".as_ptr() as *const c_char) as *mut PyTypeObject; Py_DECREF(module_dict); Py_DECREF(module); ptr } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_enum_type() -> *mut PyTypeObject { let module = PyImport_ImportModule("enum\0".as_ptr() as *const c_char); let module_dict = PyObject_GenericGetDict(module, null_mut()); let ptr = PyMapping_GetItemString(module_dict, "EnumMeta\0".as_ptr() as *const c_char) as *mut PyTypeObject; Py_DECREF(module_dict); Py_DECREF(module); ptr } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_uuid_type() -> *mut PyTypeObject { let uuid_mod = PyImport_ImportModule("uuid\0".as_ptr() as *const c_char); let uuid_mod_dict = PyObject_GenericGetDict(uuid_mod, null_mut()); let uuid = PyMapping_GetItemString(uuid_mod_dict, "NAMESPACE_DNS\0".as_ptr() as *const c_char); let ptr = (*uuid).ob_type; Py_DECREF(uuid); Py_DECREF(uuid_mod_dict); Py_DECREF(uuid_mod); ptr } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_datetime_type() -> *mut PyTypeObject { let datetime = ((*PyDateTimeAPI()).DateTime_FromDateAndTime)( 1970, 1, 1, 0, 0, 0, 0, NONE, (*(PyDateTimeAPI())).DateTimeType, ); let ptr = (*datetime).ob_type; Py_DECREF(datetime); ptr } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_date_type() -> *mut PyTypeObject { let date = ((*PyDateTimeAPI()).Date_FromDate)(1, 1, 1, (*(PyDateTimeAPI())).DateType); let ptr = (*date).ob_type; Py_DECREF(date); ptr } #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_time_type() -> *mut PyTypeObject { let time = ((*PyDateTimeAPI()).Time_FromTime)(0, 0, 0, 0, NONE, (*(PyDateTimeAPI())).TimeType); let ptr = (*time).ob_type; Py_DECREF(time); ptr } #[cfg(Py_3_9)] #[cold] #[cfg_attr(feature = "optimize", optimize(size))] unsafe fn look_up_zoneinfo_type() -> *mut PyTypeObject { let module = PyImport_ImportModule("zoneinfo\0".as_ptr() as *const c_char); let module_dict = PyObject_GenericGetDict(module, null_mut()); let ptr = PyMapping_GetItemString(module_dict, "ZoneInfo\0".as_ptr() as *const c_char) as *mut PyTypeObject; Py_DECREF(module_dict); Py_DECREF(module); ptr } orjson-3.9.15/src/util.rs000066400000000000000000000131131456615046100152440ustar00rootroot00000000000000// SPDX-License-Identifier: (Apache-2.0 OR MIT) pub const INVALID_STR: &str = "str is not valid UTF-8: surrogates not allowed"; macro_rules! is_type { ($obj_ptr:expr, $type_ptr:expr) => { unsafe { $obj_ptr == $type_ptr } }; } macro_rules! ob_type { ($obj:expr) => { unsafe { (*$obj).ob_type } }; } macro_rules! is_class_by_type { ($ob_type:expr, $type_ptr:ident) => { unsafe { $ob_type == $type_ptr } }; } macro_rules! is_subclass_by_flag { ($ob_type:expr, $flag:ident) => { unsafe { (((*$ob_type).tp_flags & pyo3_ffi::$flag) != 0) } }; } macro_rules! is_subclass_by_type { ($ob_type:expr, $type:ident) => { unsafe { (*($ob_type as *mut pyo3_ffi::PyTypeObject)) .ob_base .ob_base .ob_type == $type } }; } macro_rules! err { ($msg:expr) => { return Err(serde::ser::Error::custom($msg)) }; } macro_rules! opt_enabled { ($var:expr, $flag:expr) => { $var & $flag != 0 }; } macro_rules! opt_disabled { ($var:expr, $flag:expr) => { $var & $flag == 0 }; } #[cfg(feature = "intrinsics")] macro_rules! unlikely { ($exp:expr) => { core::intrinsics::unlikely($exp) }; } #[cfg(not(feature = "intrinsics"))] macro_rules! unlikely { ($exp:expr) => { $exp }; } #[allow(unused_macros)] #[cfg(feature = "intrinsics")] macro_rules! likely { ($exp:expr) => { core::intrinsics::likely($exp) }; } #[allow(unused_macros)] #[cfg(not(feature = "intrinsics"))] macro_rules! likely { ($exp:expr) => { $exp }; } macro_rules! nonnull { ($exp:expr) => { unsafe { core::ptr::NonNull::new_unchecked($exp) } }; } macro_rules! str_from_slice { ($ptr:expr, $size:expr) => { unsafe { std::str::from_utf8_unchecked(core::slice::from_raw_parts($ptr, $size as usize)) } }; } #[cfg(Py_3_12)] macro_rules! reverse_pydict_incref { ($op:expr) => { unsafe { if pyo3_ffi::_Py_IsImmortal($op) == 0 { debug_assert!(ffi!(Py_REFCNT($op)) >= 2); (*$op).ob_refcnt.ob_refcnt -= 1; } } }; } #[cfg(not(Py_3_12))] macro_rules! reverse_pydict_incref { ($op:expr) => { unsafe { debug_assert!(ffi!(Py_REFCNT($op)) >= 2); (*$op).ob_refcnt -= 1; } }; } macro_rules! ffi { ($fn:ident()) => { unsafe { pyo3_ffi::$fn() } }; ($fn:ident($obj1:expr)) => { unsafe { pyo3_ffi::$fn($obj1) } }; ($fn:ident($obj1:expr, $obj2:expr)) => { unsafe { pyo3_ffi::$fn($obj1, $obj2) } }; ($fn:ident($obj1:expr, $obj2:expr, $obj3:expr)) => { unsafe { pyo3_ffi::$fn($obj1, $obj2, $obj3) } }; ($fn:ident($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr)) => { unsafe { pyo3_ffi::$fn($obj1, $obj2, $obj3, $obj4) } }; } #[cfg(Py_3_9)] macro_rules! call_method { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::PyObject_CallMethodNoArgs($obj1, $obj2) } }; ($obj1:expr, $obj2:expr, $obj3:expr) => { unsafe { pyo3_ffi::PyObject_CallMethodOneArg($obj1, $obj2, $obj3) } }; } #[cfg(not(Py_3_9))] macro_rules! call_method { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::PyObject_CallMethodObjArgs( $obj1, $obj2, core::ptr::null_mut() as *mut pyo3_ffi::PyObject, ) } }; ($obj1:expr, $obj2:expr, $obj3:expr) => { unsafe { pyo3_ffi::PyObject_CallMethodObjArgs( $obj1, $obj2, $obj3, core::ptr::null_mut() as *mut pyo3_ffi::PyObject, ) } }; } macro_rules! str_hash { ($op:expr) => { unsafe { (*$op.cast::()).hash } }; } #[cfg(Py_3_13)] macro_rules! pydict_contains { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::PyDict_Contains(pyo3_ffi::PyType_GetDict($obj1), $obj2) == 1 } }; } #[cfg(all(Py_3_12, not(Py_3_13)))] macro_rules! pydict_contains { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::_PyDict_Contains_KnownHash( pyo3_ffi::PyType_GetDict($obj1), $obj2, (*$obj2.cast::()).hash, ) == 1 } }; } #[cfg(all(Py_3_10, not(Py_3_12)))] macro_rules! pydict_contains { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::_PyDict_Contains_KnownHash( (*$obj1).tp_dict, $obj2, (*$obj2.cast::()).hash, ) == 1 } }; } #[cfg(not(Py_3_10))] macro_rules! pydict_contains { ($obj1:expr, $obj2:expr) => { unsafe { pyo3_ffi::PyDict_Contains((*$obj1).tp_dict, $obj2) == 1 } }; } #[cfg(Py_3_12)] macro_rules! use_immortal { ($op:expr) => { unsafe { $op } }; } #[cfg(not(Py_3_12))] macro_rules! use_immortal { ($op:expr) => { unsafe { ffi!(Py_INCREF($op)); $op } }; } #[cfg(not(Py_3_13))] macro_rules! pydict_next { ($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => { unsafe { pyo3_ffi::_PyDict_Next($obj1, $obj2, $obj3, $obj4, core::ptr::null_mut()) } }; } #[cfg(Py_3_13)] macro_rules! pydict_next { ($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => { unsafe { pyo3_ffi::PyDict_Next($obj1, $obj2, $obj3, $obj4) } }; } macro_rules! reserve_minimum { ($writer:expr) => { $writer.reserve(64); }; } orjson-3.9.15/test/000077500000000000000000000000001456615046100141125ustar00rootroot00000000000000orjson-3.9.15/test/__init__.py000066400000000000000000000000001456615046100162110ustar00rootroot00000000000000orjson-3.9.15/test/requirements.txt000066400000000000000000000007651456615046100174060ustar00rootroot00000000000000arrow faker numpy;(platform_machine=="x86_64" or (platform_machine=="aarch64" and sys_platform == "linux")) and python_version<"3.12" pendulum;sys_platform=="linux" and platform_machine=="x86_64" and python_version<"3.12" psutil;(sys_platform=="linux" or sys_platform == "macos") and platform_machine=="x86_64" pytest pytz typing_extensions;python_version<"3.8" xxhash==1.4.3;sys_platform=="linux" and platform_machine=="x86_64" and python_version<"3.9" # creates non-compact ASCII for test_str_ascii orjson-3.9.15/test/test_api.py000066400000000000000000000205551456615046100163030ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import datetime import inspect import json import re import pytest import orjson SIMPLE_TYPES = (1, 1.0, -1, None, "str", True, False) LOADS_RECURSION_LIMIT = 1024 def default(obj): return str(obj) class TestApi: def test_loads_trailing(self): """ loads() handles trailing whitespace """ assert orjson.loads("{}\n\t ") == {} def test_loads_trailing_invalid(self): """ loads() handles trailing invalid """ pytest.raises(orjson.JSONDecodeError, orjson.loads, "{}\n\t a") def test_simple_json(self): """ dumps() equivalent to json on simple types """ for obj in SIMPLE_TYPES: assert orjson.dumps(obj) == json.dumps(obj).encode("utf-8") def test_simple_round_trip(self): """ dumps(), loads() round trip on simple types """ for obj in SIMPLE_TYPES: assert orjson.loads(orjson.dumps(obj)) == obj def test_loads_type(self): """ loads() invalid type """ for val in (1, 3.14, [], {}, None): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_loads_recursion_partial(self): """ loads() recursion limit partial """ pytest.raises(orjson.JSONDecodeError, orjson.loads, "[" * (1024 * 1024)) def test_loads_recursion_valid_limit_array(self): """ loads() recursion limit at limit array """ n = LOADS_RECURSION_LIMIT + 1 value = b"[" * n + b"]" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_limit_object(self): """ loads() recursion limit at limit object """ n = LOADS_RECURSION_LIMIT value = b'{"key":' * n + b'{"key":true}' + b"}" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_limit_mixed(self): """ loads() recursion limit at limit mixed """ n = LOADS_RECURSION_LIMIT value = b"[" b'{"key":' * n + b'{"key":true}' + b"}" * n + b"]" pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_excessive_array(self): """ loads() recursion limit excessively high value """ n = 10000000 value = b"[" * n + b"]" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_limit_array_pretty(self): """ loads() recursion limit at limit array pretty """ n = LOADS_RECURSION_LIMIT + 1 value = b"[\n " * n + b"]" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_limit_object_pretty(self): """ loads() recursion limit at limit object pretty """ n = LOADS_RECURSION_LIMIT value = b'{\n "key":' * n + b'{"key":true}' + b"}" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_limit_mixed_pretty(self): """ loads() recursion limit at limit mixed pretty """ n = LOADS_RECURSION_LIMIT value = b"[\n " b'{"key":' * n + b'{"key":true}' + b"}" * n + b"]" pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_loads_recursion_valid_excessive_array_pretty(self): """ loads() recursion limit excessively high value pretty """ n = 10000000 value = b"[\n " * n + b"]" * n pytest.raises(orjson.JSONDecodeError, orjson.loads, value) def test_version(self): """ __version__ """ assert re.match(r"^\d+\.\d+(\.\d+)?$", orjson.__version__) def test_valueerror(self): """ orjson.JSONDecodeError is a subclass of ValueError """ pytest.raises(orjson.JSONDecodeError, orjson.loads, "{") pytest.raises(ValueError, orjson.loads, "{") def test_optional_none(self): """ dumps() option, default None """ assert orjson.dumps([], option=None) == b"[]" assert orjson.dumps([], default=None) == b"[]" assert orjson.dumps([], option=None, default=None) == b"[]" assert orjson.dumps([], None, None) == b"[]" def test_option_not_int(self): """ dumps() option not int or None """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(True, option=True) def test_option_invalid_int(self): """ dumps() option invalid 64-bit number """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(True, option=9223372036854775809) def test_option_range_low(self): """ dumps() option out of range low """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(True, option=-1) def test_option_range_high(self): """ dumps() option out of range high """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(True, option=1 << 12) def test_opts_multiple(self): """ dumps() multiple option """ assert ( orjson.dumps( [1, datetime.datetime(2000, 1, 1, 2, 3, 4)], option=orjson.OPT_STRICT_INTEGER | orjson.OPT_NAIVE_UTC, ) == b'[1,"2000-01-01T02:03:04+00:00"]' ) def test_default_positional(self): """ dumps() positional arg """ with pytest.raises(TypeError): orjson.dumps(__obj={}) # type: ignore with pytest.raises(TypeError): orjson.dumps(zxc={}) # type: ignore def test_default_unknown_kwarg(self): """ dumps() unknown kwarg """ with pytest.raises(TypeError): orjson.dumps({}, zxc=default) # type: ignore def test_default_empty_kwarg(self): """ dumps() empty kwarg """ assert orjson.dumps(None, **{}) == b"null" def test_default_twice(self): """ dumps() default twice """ with pytest.raises(TypeError): orjson.dumps({}, default, default=default) # type: ignore def test_option_twice(self): """ dumps() option twice """ with pytest.raises(TypeError): orjson.dumps({}, None, orjson.OPT_NAIVE_UTC, option=orjson.OPT_NAIVE_UTC) # type: ignore def test_option_mixed(self): """ dumps() option one arg, one kwarg """ class Custom: def __str__(self): return "zxc" assert ( orjson.dumps( [Custom(), datetime.datetime(2000, 1, 1, 2, 3, 4)], default, option=orjson.OPT_NAIVE_UTC, ) == b'["zxc","2000-01-01T02:03:04+00:00"]' ) def test_dumps_signature(self): """ dumps() valid __text_signature__ """ assert ( str(inspect.signature(orjson.dumps)) == "(obj, /, default=None, option=None)" ) inspect.signature(orjson.dumps).bind("str") inspect.signature(orjson.dumps).bind("str", default=default, option=1) inspect.signature(orjson.dumps).bind("str", default=None, option=None) def test_loads_signature(self): """ loads() valid __text_signature__ """ assert str(inspect.signature(orjson.loads)), "(obj == /)" inspect.signature(orjson.loads).bind("[]") def test_dumps_module_str(self): """ orjson.dumps.__module__ is a str """ assert orjson.dumps.__module__ == "orjson" def test_loads_module_str(self): """ orjson.loads.__module__ is a str """ assert orjson.loads.__module__ == "orjson" def test_bytes_buffer(self): """ dumps() trigger buffer growing where length is greater than growth """ a = "a" * 900 b = "b" * 4096 c = "c" * 4096 * 4096 assert orjson.dumps([a, b, c]) == f'["{a}","{b}","{c}"]'.encode("utf-8") def test_bytes_null_terminated(self): """ dumps() PyBytesObject buffer is null-terminated """ # would raise ValueError: invalid literal for int() with base 10: b'1596728892' int(orjson.dumps(1596728892)) orjson-3.9.15/test/test_append_newline.py000066400000000000000000000024471456615046100205220ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson from .util import read_fixture_obj class TestAppendNewline: def test_dumps_newline(self): """ dumps() OPT_APPEND_NEWLINE """ assert orjson.dumps([], option=orjson.OPT_APPEND_NEWLINE) == b"[]\n" def test_twitter_newline(self): """ loads(),dumps() twitter.json OPT_APPEND_NEWLINE """ val = read_fixture_obj("twitter.json.xz") assert orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)) == val def test_canada(self): """ loads(), dumps() canada.json OPT_APPEND_NEWLINE """ val = read_fixture_obj("canada.json.xz") assert orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)) == val def test_citm_catalog_newline(self): """ loads(), dumps() citm_catalog.json OPT_APPEND_NEWLINE """ val = read_fixture_obj("citm_catalog.json.xz") assert orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)) == val def test_github_newline(self): """ loads(), dumps() github.json OPT_APPEND_NEWLINE """ val = read_fixture_obj("github.json.xz") assert orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)) == val orjson-3.9.15/test/test_canonical.py000066400000000000000000000012501456615046100174500ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson class TestCanonicalTests: def test_dumps_ctrl_escape(self): """ dumps() ctrl characters """ assert orjson.dumps("text\u0003\r\n") == b'"text\\u0003\\r\\n"' def test_dumps_escape_quote_backslash(self): """ dumps() quote, backslash escape """ assert orjson.dumps(r'"\ test') == b'"\\"\\\\ test"' def test_dumps_escape_line_separator(self): """ dumps() U+2028, U+2029 escape """ assert ( orjson.dumps({"spaces": "\u2028 \u2029"}) == b'{"spaces":"\xe2\x80\xa8 \xe2\x80\xa9"}' ) orjson-3.9.15/test/test_circular.py000066400000000000000000000040611456615046100173300ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson class TestCircular: def test_circular_dict(self): """ dumps() circular reference dict """ obj = {} # type: ignore obj["obj"] = obj with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) def test_circular_dict_sort_keys(self): """ dumps() circular reference dict OPT_SORT_KEYS """ obj = {} # type: ignore obj["obj"] = obj with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) def test_circular_dict_non_str_keys(self): """ dumps() circular reference dict OPT_NON_STR_KEYS """ obj = {} # type: ignore obj["obj"] = obj with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS) def test_circular_list(self): """ dumps() circular reference list """ obj = [] # type: ignore obj.append(obj) # type: ignore with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) def test_circular_nested(self): """ dumps() circular reference nested dict, list """ obj = {} # type: ignore obj["list"] = [{"obj": obj}] with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) def test_circular_nested_sort_keys(self): """ dumps() circular reference nested dict, list OPT_SORT_KEYS """ obj = {} # type: ignore obj["list"] = [{"obj": obj}] with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) def test_circular_nested_non_str_keys(self): """ dumps() circular reference nested dict, list OPT_NON_STR_KEYS """ obj = {} # type: ignore obj["list"] = [{"obj": obj}] with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS) orjson-3.9.15/test/test_dataclass.py000066400000000000000000000161701456615046100174670ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import abc import uuid from dataclasses import InitVar, asdict, dataclass, field from enum import Enum from typing import ClassVar, Dict, Optional import pytest import orjson class AnEnum(Enum): ONE = 1 TWO = 2 @dataclass class EmptyDataclass: pass @dataclass class EmptyDataclassSlots: __slots__ = () @dataclass class Dataclass1: name: str number: int sub: Optional["Dataclass1"] @dataclass class Dataclass2: name: Optional[str] = field(default="?") @dataclass class Dataclass3: a: str b: int c: dict d: bool e: float f: list g: tuple @dataclass class Dataclass4: a: str = field() b: int = field(metadata={"unrelated": False}) c: float = 1.1 @dataclass class Datasubclass(Dataclass1): additional: bool @dataclass class Slotsdataclass: __slots__ = ("a", "b", "_c", "d") a: str b: int _c: str d: InitVar[str] cls_var: ClassVar[str] = "cls" @dataclass class Defaultdataclass: a: uuid.UUID b: AnEnum @dataclass class UnsortedDataclass: c: int b: int a: int d: Optional[Dict] @dataclass class InitDataclass: a: InitVar[str] b: InitVar[str] cls_var: ClassVar[str] = "cls" ab: str = "" def __post_init__(self, a: str, b: str): self._other = 1 self.ab = f"{a} {b}" class AbstractBase(abc.ABC): @abc.abstractmethod def key(self): raise NotImplementedError @dataclass(frozen=True) class ConcreteAbc(AbstractBase): __slots__ = ("attr",) attr: float def key(self): return "dkjf" class TestDataclass: def test_dataclass(self): """ dumps() dataclass """ obj = Dataclass1("a", 1, None) assert orjson.dumps(obj) == b'{"name":"a","number":1,"sub":null}' def test_dataclass_recursive(self): """ dumps() dataclass recursive """ obj = Dataclass1("a", 1, Dataclass1("b", 2, None)) assert ( orjson.dumps(obj) == b'{"name":"a","number":1,"sub":{"name":"b","number":2,"sub":null}}' ) def test_dataclass_circular(self): """ dumps() dataclass circular """ obj1 = Dataclass1("a", 1, None) obj2 = Dataclass1("b", 2, obj1) obj1.sub = obj2 with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj1) def test_dataclass_empty(self): """ dumps() no attributes """ assert orjson.dumps(EmptyDataclass()) == b"{}" def test_dataclass_empty_slots(self): """ dumps() no attributes slots """ assert orjson.dumps(EmptyDataclassSlots()) == b"{}" def test_dataclass_default_arg(self): """ dumps() dataclass default arg """ obj = Dataclass2() assert orjson.dumps(obj) == b'{"name":"?"}' def test_dataclass_types(self): """ dumps() dataclass types """ obj = Dataclass3("a", 1, {"a": "b"}, True, 1.1, [1, 2], (3, 4)) assert ( orjson.dumps(obj) == b'{"a":"a","b":1,"c":{"a":"b"},"d":true,"e":1.1,"f":[1,2],"g":[3,4]}' ) def test_dataclass_metadata(self): """ dumps() dataclass metadata """ obj = Dataclass4("a", 1, 2.1) assert orjson.dumps(obj) == b'{"a":"a","b":1,"c":2.1}' def test_dataclass_classvar(self): """ dumps() dataclass class variable """ obj = Dataclass4("a", 1) assert orjson.dumps(obj) == b'{"a":"a","b":1,"c":1.1}' def test_dataclass_subclass(self): """ dumps() dataclass subclass """ obj = Datasubclass("a", 1, None, False) assert ( orjson.dumps(obj) == b'{"name":"a","number":1,"sub":null,"additional":false}' ) def test_dataclass_slots(self): """ dumps() dataclass with __slots__ does not include under attributes, InitVar, or ClassVar """ obj = Slotsdataclass("a", 1, "c", "d") assert "__dict__" not in dir(obj) assert orjson.dumps(obj) == b'{"a":"a","b":1}' def test_dataclass_default(self): """ dumps() dataclass with default """ def default(__obj): if isinstance(__obj, uuid.UUID): return str(__obj) elif isinstance(__obj, Enum): return __obj.value obj = Defaultdataclass( uuid.UUID("808989c0-00d5-48a8-b5c4-c804bf9032f2"), AnEnum.ONE ) assert ( orjson.dumps(obj, default=default) == b'{"a":"808989c0-00d5-48a8-b5c4-c804bf9032f2","b":1}' ) def test_dataclass_sort(self): """ OPT_SORT_KEYS has no effect on dataclasses """ obj = UnsortedDataclass(1, 2, 3, None) assert ( orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) == b'{"c":1,"b":2,"a":3,"d":null}' ) def test_dataclass_sort_sub(self): """ dataclass fast path does not prevent OPT_SORT_KEYS from cascading """ obj = UnsortedDataclass(1, 2, 3, {"f": 2, "e": 1}) assert ( orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) == b'{"c":1,"b":2,"a":3,"d":{"e":1,"f":2}}' ) def test_dataclass_under(self): """ dumps() does not include under attributes, InitVar, or ClassVar """ obj = InitDataclass("zxc", "vbn") assert orjson.dumps(obj) == b'{"ab":"zxc vbn"}' def test_dataclass_option(self): """ dumps() accepts deprecated OPT_SERIALIZE_DATACLASS """ obj = Dataclass1("a", 1, None) assert ( orjson.dumps(obj, option=orjson.OPT_SERIALIZE_DATACLASS) == b'{"name":"a","number":1,"sub":null}' ) class TestDataclassPassthrough: def test_dataclass_passthrough_raise(self): """ dumps() dataclass passes to default with OPT_PASSTHROUGH_DATACLASS """ obj = Dataclass1("a", 1, None) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_PASSTHROUGH_DATACLASS) with pytest.raises(orjson.JSONEncodeError): orjson.dumps( InitDataclass("zxc", "vbn"), option=orjson.OPT_PASSTHROUGH_DATACLASS ) def test_dataclass_passthrough_default(self): """ dumps() dataclass passes to default with OPT_PASSTHROUGH_DATACLASS """ obj = Dataclass1("a", 1, None) assert ( orjson.dumps(obj, option=orjson.OPT_PASSTHROUGH_DATACLASS, default=asdict) == b'{"name":"a","number":1,"sub":null}' ) def default(obj): if isinstance(obj, Dataclass1): return {"name": obj.name, "number": obj.number} raise TypeError assert ( orjson.dumps(obj, option=orjson.OPT_PASSTHROUGH_DATACLASS, default=default) == b'{"name":"a","number":1}' ) class TestAbstractDataclass: def test_dataclass_abc(self): obj = ConcreteAbc(1.0) assert orjson.dumps(obj) == b'{"attr":1.0}' orjson-3.9.15/test/test_datetime.py000066400000000000000000000542711456615046100173300ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import datetime import pytest import orjson try: import zoneinfo _ = zoneinfo.ZoneInfo("Europe/Amsterdam") except Exception: # ImportError,ZoneInfoNotFoundError zoneinfo = None # type: ignore try: import pytz except ImportError: pytz = None # type: ignore try: import pendulum except ImportError: pendulum = None # type: ignore try: from dateutil import tz except ImportError: tz = None # type: ignore AMSTERDAM_1937_DATETIMES = ( b'["1937-01-01T12:00:27.000087+00:20"]', # tzinfo<2022b and an example in RFC 3339 b'["1937-01-01T12:00:27.000087+00:00"]', # tzinfo>=2022b ) AMSTERDAM_1937_DATETIMES_WITH_Z = ( b'["1937-01-01T12:00:27.000087+00:20"]', b'["1937-01-01T12:00:27.000087Z"]', ) class TestDatetime: def test_datetime_naive(self): """ datetime.datetime naive prints without offset """ assert ( orjson.dumps([datetime.datetime(2000, 1, 1, 2, 3, 4, 123)]) == b'["2000-01-01T02:03:04.000123"]' ) def test_datetime_naive_utc(self): """ datetime.datetime naive with opt assumes UTC """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_NAIVE_UTC, ) == b'["2000-01-01T02:03:04.000123+00:00"]' ) def test_datetime_min(self): """ datetime.datetime min range """ assert ( orjson.dumps( [datetime.datetime(datetime.MINYEAR, 1, 1, 0, 0, 0, 0)], option=orjson.OPT_NAIVE_UTC, ) == b'["0001-01-01T00:00:00+00:00"]' ) def test_datetime_max(self): """ datetime.datetime max range """ assert ( orjson.dumps( [datetime.datetime(datetime.MAXYEAR, 12, 31, 23, 59, 50, 999999)], option=orjson.OPT_NAIVE_UTC, ) == b'["9999-12-31T23:59:50.999999+00:00"]' ) def test_datetime_three_digits(self): """ datetime.datetime three digit year """ assert ( orjson.dumps( [datetime.datetime(312, 1, 1)], option=orjson.OPT_NAIVE_UTC, ) == b'["0312-01-01T00:00:00+00:00"]' ) def test_datetime_two_digits(self): """ datetime.datetime two digit year """ assert ( orjson.dumps( [datetime.datetime(46, 1, 1)], option=orjson.OPT_NAIVE_UTC, ) == b'["0046-01-01T00:00:00+00:00"]' ) @pytest.mark.skipif(tz is None, reason="dateutil optional") def test_datetime_tz_assume(self): """ datetime.datetime tz with assume UTC uses tz """ assert ( orjson.dumps( [ datetime.datetime( 2018, 1, 1, 2, 3, 4, 0, tzinfo=tz.gettz("Asia/Shanghai") ) ], option=orjson.OPT_NAIVE_UTC, ) == b'["2018-01-01T02:03:04+08:00"]' ) def test_datetime_timezone_utc(self): """ datetime.datetime.utc """ assert ( orjson.dumps( [ datetime.datetime( 2018, 6, 1, 2, 3, 4, 0, tzinfo=datetime.timezone.utc ) ] ) == b'["2018-06-01T02:03:04+00:00"]' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_pytz_utc(self): """ pytz.UTC """ assert ( orjson.dumps([datetime.datetime(2018, 6, 1, 2, 3, 4, 0, tzinfo=pytz.UTC)]) == b'["2018-06-01T02:03:04+00:00"]' ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_zoneinfo_utc(self): """ zoneinfo.ZoneInfo("UTC") """ assert ( orjson.dumps( [ datetime.datetime( 2018, 6, 1, 2, 3, 4, 0, tzinfo=zoneinfo.ZoneInfo("UTC") ) ] ) == b'["2018-06-01T02:03:04+00:00"]' ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_zoneinfo_positive(self): assert ( orjson.dumps( [ datetime.datetime( 2018, 1, 1, 2, 3, 4, 0, tzinfo=zoneinfo.ZoneInfo("Asia/Shanghai"), ) ] ) == b'["2018-01-01T02:03:04+08:00"]' ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_zoneinfo_negative(self): assert ( orjson.dumps( [ datetime.datetime( 2018, 6, 1, 2, 3, 4, 0, tzinfo=zoneinfo.ZoneInfo("America/New_York"), ) ] ) == b'["2018-06-01T02:03:04-04:00"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_pendulum_utc(self): """ datetime.datetime UTC """ assert ( orjson.dumps( [datetime.datetime(2018, 6, 1, 2, 3, 4, 0, tzinfo=pendulum.UTC)] ) == b'["2018-06-01T02:03:04+00:00"]' ) @pytest.mark.skipif(tz is None, reason="dateutil optional") def test_datetime_arrow_positive(self): """ datetime.datetime positive UTC """ assert ( orjson.dumps( [ datetime.datetime( 2018, 1, 1, 2, 3, 4, 0, tzinfo=tz.gettz("Asia/Shanghai") ) ] ) == b'["2018-01-01T02:03:04+08:00"]' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_pytz_positive(self): """ datetime.datetime positive UTC """ assert ( orjson.dumps( [ datetime.datetime( 2018, 1, 1, 2, 3, 4, 0, tzinfo=pytz.timezone("Asia/Shanghai") ) ] ) == b'["2018-01-01T02:03:04+08:00"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_pendulum_positive(self): """ datetime.datetime positive UTC """ assert ( orjson.dumps( [ datetime.datetime( 2018, 1, 1, 2, 3, 4, 0, tzinfo=pendulum.timezone("Asia/Shanghai"), # type: ignore ) ] ) == b'["2018-01-01T02:03:04+08:00"]' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_pytz_negative_dst(self): """ datetime.datetime negative UTC DST """ assert ( orjson.dumps( [ datetime.datetime( 2018, 6, 1, 2, 3, 4, 0, tzinfo=pytz.timezone("America/New_York") ) ] ) == b'["2018-06-01T02:03:04-04:00"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_pendulum_negative_dst(self): """ datetime.datetime negative UTC DST """ assert ( orjson.dumps( [ datetime.datetime( 2018, 6, 1, 2, 3, 4, 0, tzinfo=pendulum.timezone("America/New_York"), # type: ignore ) ] ) == b'["2018-06-01T02:03:04-04:00"]' ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_zoneinfo_negative_non_dst(self): """ datetime.datetime negative UTC non-DST """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=zoneinfo.ZoneInfo("America/New_York"), ) ] ) == b'["2018-12-01T02:03:04-05:00"]' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_pytz_negative_non_dst(self): """ datetime.datetime negative UTC non-DST """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=pytz.timezone("America/New_York"), ) ] ) == b'["2018-12-01T02:03:04-05:00"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_pendulum_negative_non_dst(self): """ datetime.datetime negative UTC non-DST """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=pendulum.timezone("America/New_York"), # type: ignore ) ] ) == b'["2018-12-01T02:03:04-05:00"]' ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_zoneinfo_partial_hour(self): """ datetime.datetime UTC offset partial hour """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=zoneinfo.ZoneInfo("Australia/Adelaide"), ) ] ) == b'["2018-12-01T02:03:04+10:30"]' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_pytz_partial_hour(self): """ datetime.datetime UTC offset partial hour """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=pytz.timezone("Australia/Adelaide"), ) ] ) == b'["2018-12-01T02:03:04+10:30"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_pendulum_partial_hour(self): """ datetime.datetime UTC offset partial hour """ assert ( orjson.dumps( [ datetime.datetime( 2018, 12, 1, 2, 3, 4, 0, tzinfo=pendulum.timezone("Australia/Adelaide"), # type: ignore ) ] ) == b'["2018-12-01T02:03:04+10:30"]' ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_partial_second_pendulum_supported(self): """ datetime.datetime UTC offset round seconds https://tools.ietf.org/html/rfc3339#section-5.8 """ assert ( orjson.dumps( [ datetime.datetime( 1937, 1, 1, 12, 0, 27, 87, tzinfo=pendulum.timezone("Europe/Amsterdam"), # type: ignore ) ] ) in AMSTERDAM_1937_DATETIMES ) @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_datetime_partial_second_zoneinfo(self): """ datetime.datetime UTC offset round seconds https://tools.ietf.org/html/rfc3339#section-5.8 """ assert ( orjson.dumps( [ datetime.datetime( 1937, 1, 1, 12, 0, 27, 87, tzinfo=zoneinfo.ZoneInfo("Europe/Amsterdam"), ) ] ) in AMSTERDAM_1937_DATETIMES ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_datetime_partial_second_pytz(self): """ datetime.datetime UTC offset round seconds https://tools.ietf.org/html/rfc3339#section-5.8 """ assert ( orjson.dumps( [ datetime.datetime( 1937, 1, 1, 12, 0, 27, 87, tzinfo=pytz.timezone("Europe/Amsterdam"), ) ] ) in AMSTERDAM_1937_DATETIMES ) @pytest.mark.skipif(tz is None, reason="dateutil optional") def test_datetime_partial_second_dateutil(self): """ datetime.datetime UTC offset round seconds https://tools.ietf.org/html/rfc3339#section-5.8 """ assert ( orjson.dumps( [ datetime.datetime( 1937, 1, 1, 12, 0, 27, 87, tzinfo=tz.gettz("Europe/Amsterdam") ) ] ) in AMSTERDAM_1937_DATETIMES ) def test_datetime_microsecond_max(self): """ datetime.datetime microsecond max """ assert ( orjson.dumps(datetime.datetime(2000, 1, 1, 0, 0, 0, 999999)) == b'"2000-01-01T00:00:00.999999"' ) def test_datetime_microsecond_min(self): """ datetime.datetime microsecond min """ assert ( orjson.dumps(datetime.datetime(2000, 1, 1, 0, 0, 0, 1)) == b'"2000-01-01T00:00:00.000001"' ) def test_datetime_omit_microseconds(self): """ datetime.datetime OPT_OMIT_MICROSECONDS """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_OMIT_MICROSECONDS, ) == b'["2000-01-01T02:03:04"]' ) def test_datetime_omit_microseconds_naive(self): """ datetime.datetime naive OPT_OMIT_MICROSECONDS """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_NAIVE_UTC | orjson.OPT_OMIT_MICROSECONDS, ) == b'["2000-01-01T02:03:04+00:00"]' ) def test_time_omit_microseconds(self): """ datetime.time OPT_OMIT_MICROSECONDS """ assert ( orjson.dumps( [datetime.time(2, 3, 4, 123)], option=orjson.OPT_OMIT_MICROSECONDS ) == b'["02:03:04"]' ) def test_datetime_utc_z_naive_omit(self): """ datetime.datetime naive OPT_UTC_Z """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_NAIVE_UTC | orjson.OPT_UTC_Z | orjson.OPT_OMIT_MICROSECONDS, ) == b'["2000-01-01T02:03:04Z"]' ) def test_datetime_utc_z_naive(self): """ datetime.datetime naive OPT_UTC_Z """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_NAIVE_UTC | orjson.OPT_UTC_Z, ) == b'["2000-01-01T02:03:04.000123Z"]' ) def test_datetime_utc_z_without_tz(self): """ datetime.datetime naive OPT_UTC_Z """ assert ( orjson.dumps( [datetime.datetime(2000, 1, 1, 2, 3, 4, 123)], option=orjson.OPT_UTC_Z ) == b'["2000-01-01T02:03:04.000123"]' ) @pytest.mark.skipif(tz is None, reason="dateutil optional") def test_datetime_utc_z_with_tz(self): """ datetime.datetime naive OPT_UTC_Z """ assert ( orjson.dumps( [ datetime.datetime( 2000, 1, 1, 0, 0, 0, 1, tzinfo=datetime.timezone.utc ) ], option=orjson.OPT_UTC_Z, ) == b'["2000-01-01T00:00:00.000001Z"]' ) assert ( orjson.dumps( [ datetime.datetime( 1937, 1, 1, 12, 0, 27, 87, tzinfo=tz.gettz("Europe/Amsterdam") ) ], option=orjson.OPT_UTC_Z, ) in AMSTERDAM_1937_DATETIMES_WITH_Z ) @pytest.mark.skipif(pendulum is None, reason="pendulum not installed") def test_datetime_roundtrip(self): """ datetime.datetime parsed by pendulum """ obj = datetime.datetime(2000, 1, 1, 0, 0, 0, 1, tzinfo=datetime.timezone.utc) serialized = orjson.dumps(obj).decode("utf-8").replace('"', "") parsed = pendulum.parse(serialized) for attr in ("year", "month", "day", "hour", "minute", "second", "microsecond"): assert getattr(obj, attr) == getattr(parsed, attr) class TestDate: def test_date(self): """ datetime.date """ assert orjson.dumps([datetime.date(2000, 1, 13)]) == b'["2000-01-13"]' def test_date_min(self): """ datetime.date MINYEAR """ assert ( orjson.dumps([datetime.date(datetime.MINYEAR, 1, 1)]) == b'["0001-01-01"]' ) def test_date_max(self): """ datetime.date MAXYEAR """ assert ( orjson.dumps([datetime.date(datetime.MAXYEAR, 12, 31)]) == b'["9999-12-31"]' ) def test_date_three_digits(self): """ datetime.date three digit year """ assert ( orjson.dumps( [datetime.date(312, 1, 1)], ) == b'["0312-01-01"]' ) def test_date_two_digits(self): """ datetime.date two digit year """ assert ( orjson.dumps( [datetime.date(46, 1, 1)], ) == b'["0046-01-01"]' ) class TestTime: def test_time(self): """ datetime.time """ assert orjson.dumps([datetime.time(12, 15, 59, 111)]) == b'["12:15:59.000111"]' assert orjson.dumps([datetime.time(12, 15, 59)]) == b'["12:15:59"]' @pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available") def test_time_tz(self): """ datetime.time with tzinfo error """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps( [ datetime.time( 12, 15, 59, 111, tzinfo=zoneinfo.ZoneInfo("Asia/Shanghai") ) ] ) def test_time_microsecond_max(self): """ datetime.time microsecond max """ assert orjson.dumps(datetime.time(0, 0, 0, 999999)) == b'"00:00:00.999999"' def test_time_microsecond_min(self): """ datetime.time microsecond min """ assert orjson.dumps(datetime.time(0, 0, 0, 1)) == b'"00:00:00.000001"' class TestDateclassPassthrough: def test_passthrough_datetime(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps( datetime.datetime(1970, 1, 1), option=orjson.OPT_PASSTHROUGH_DATETIME ) def test_passthrough_date(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps( datetime.date(1970, 1, 1), option=orjson.OPT_PASSTHROUGH_DATETIME ) def test_passthrough_time(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps( datetime.time(12, 0, 0), option=orjson.OPT_PASSTHROUGH_DATETIME ) def test_passthrough_datetime_default(self): def default(obj): return obj.strftime("%a, %d %b %Y %H:%M:%S GMT") assert ( orjson.dumps( datetime.datetime(1970, 1, 1), option=orjson.OPT_PASSTHROUGH_DATETIME, default=default, ) == b'"Thu, 01 Jan 1970 00:00:00 GMT"' ) orjson-3.9.15/test/test_default.py000066400000000000000000000215321456615046100171520ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import datetime import sys import uuid import pytest import orjson try: import numpy except ImportError: numpy = None # type: ignore class Custom: def __init__(self): self.name = uuid.uuid4().hex def __str__(self): return f"{self.__class__.__name__}({self.name})" class Recursive: def __init__(self, cur): self.cur = cur def default_recursive(obj): if obj.cur != 0: obj.cur -= 1 return obj return obj.cur def default_raises(obj): raise TypeError class TestType: def test_default_not_callable(self): """ dumps() default not callable """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(Custom(), default=NotImplementedError) ran = False try: orjson.dumps(Custom(), default=NotImplementedError) except Exception as err: assert isinstance(err, orjson.JSONEncodeError) assert str(err) == "default serializer exceeds recursion limit" ran = True assert ran def test_default_func(self): """ dumps() default function """ ref = Custom() def default(obj): return str(obj) assert orjson.dumps(ref, default=default) == b'"%s"' % str(ref).encode("utf-8") def test_default_func_none(self): """ dumps() default function None ok """ assert orjson.dumps(Custom(), default=lambda x: None) == b"null" def test_default_func_empty(self): """ dumps() default function no explicit return """ ref = Custom() def default(obj): if isinstance(obj, set): return list(obj) assert orjson.dumps(ref, default=default) == b"null" assert orjson.dumps({ref}, default=default) == b"[null]" def test_default_func_exc(self): """ dumps() default function raises exception """ def default(obj): raise NotImplementedError with pytest.raises(orjson.JSONEncodeError): orjson.dumps(Custom(), default=default) ran = False try: orjson.dumps(Custom(), default=default) except Exception as err: assert isinstance(err, orjson.JSONEncodeError) assert str(err) == "Type is not JSON serializable: Custom" ran = True assert ran def test_default_exception_type(self): """ dumps() TypeError in default() raises orjson.JSONEncodeError """ ref = Custom() with pytest.raises(orjson.JSONEncodeError): orjson.dumps(ref, default=default_raises) def test_default_vectorcall_str(self): """ dumps() default function vectorcall str """ class SubStr(str): pass obj = SubStr("saasa") ref = b'"%s"' % str(obj).encode("utf-8") assert ( orjson.dumps(obj, option=orjson.OPT_PASSTHROUGH_SUBCLASS, default=str) == ref ) def test_default_vectorcall_list(self): """ dumps() default function vectorcall list """ obj = {1, 2} ref = b"[1,2]" assert orjson.dumps(obj, default=list) == ref def test_default_func_nested_str(self): """ dumps() default function nested str """ ref = Custom() def default(obj): return str(obj) assert orjson.dumps({"a": ref}, default=default) == b'{"a":"%s"}' % str( ref ).encode("utf-8") def test_default_func_list(self): """ dumps() default function nested list """ ref = Custom() def default(obj): if isinstance(obj, Custom): return [str(obj)] assert orjson.dumps({"a": ref}, default=default) == b'{"a":["%s"]}' % str( ref ).encode("utf-8") def test_default_func_nested_list(self): """ dumps() default function list """ ref = Custom() def default(obj): return str(obj) assert orjson.dumps([ref] * 100, default=default) == b"[%s]" % b",".join( b'"%s"' % str(ref).encode("utf-8") for _ in range(100) ) def test_default_func_bytes(self): """ dumps() default function errors on non-str """ ref = Custom() def default(obj): return bytes(obj) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(ref, default=default) ran = False try: orjson.dumps(ref, default=default) except Exception as err: assert isinstance(err, orjson.JSONEncodeError) assert str(err) == "Type is not JSON serializable: Custom" ran = True assert ran def test_default_func_invalid_str(self): """ dumps() default function errors on invalid str """ ref = Custom() def default(obj): return "\ud800" with pytest.raises(orjson.JSONEncodeError): orjson.dumps(ref, default=default) def test_default_lambda_ok(self): """ dumps() default lambda """ ref = Custom() assert orjson.dumps(ref, default=lambda x: str(x)) == b'"%s"' % str(ref).encode( "utf-8" ) def test_default_callable_ok(self): """ dumps() default callable """ class CustomSerializer: def __init__(self): self._cache = {} def __call__(self, obj): if obj not in self._cache: self._cache[obj] = str(obj) return self._cache[obj] ref_obj = Custom() ref_bytes = b'"%s"' % str(ref_obj).encode("utf-8") for obj in [ref_obj] * 100: assert orjson.dumps(obj, default=CustomSerializer()) == ref_bytes def test_default_recursion(self): """ dumps() default recursion limit """ assert orjson.dumps(Recursive(254), default=default_recursive) == b"0" def test_default_recursion_reset(self): """ dumps() default recursion limit reset """ assert ( orjson.dumps( [Recursive(254), {"a": "b"}, Recursive(254), Recursive(254)], default=default_recursive, ) == b'[0,{"a":"b"},0,0]' ) def test_default_recursion_infinite(self): """ dumps() default infinite recursion """ ref = Custom() def default(obj): return obj refcount = sys.getrefcount(ref) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(ref, default=default) assert sys.getrefcount(ref) == refcount def test_reference_cleanup_default_custom_pass(self): ref = Custom() def default(obj): if isinstance(ref, Custom): return str(ref) raise TypeError refcount = sys.getrefcount(ref) orjson.dumps(ref, default=default) assert sys.getrefcount(ref) == refcount def test_reference_cleanup_default_custom_error(self): """ references to encoded objects are cleaned up """ ref = Custom() def default(obj): raise TypeError refcount = sys.getrefcount(ref) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(ref, default=default) assert sys.getrefcount(ref) == refcount def test_reference_cleanup_default_subclass(self): ref = datetime.datetime(1970, 1, 1, 0, 0, 0) def default(obj): if isinstance(ref, datetime.datetime): return repr(ref) raise TypeError refcount = sys.getrefcount(ref) orjson.dumps(ref, option=orjson.OPT_PASSTHROUGH_DATETIME, default=default) assert sys.getrefcount(ref) == refcount def test_reference_cleanup_default_subclass_lambda(self): ref = uuid.uuid4() refcount = sys.getrefcount(ref) orjson.dumps( ref, option=orjson.OPT_PASSTHROUGH_DATETIME, default=lambda val: str(val) ) assert sys.getrefcount(ref) == refcount @pytest.mark.skipif(numpy is None, reason="numpy is not installed") def test_default_numpy(self): ref = numpy.array([""] * 100) refcount = sys.getrefcount(ref) orjson.dumps( ref, option=orjson.OPT_SERIALIZE_NUMPY, default=lambda val: val.tolist() ) assert sys.getrefcount(ref) == refcount def test_default_set(self): """ dumps() default function with set """ def default(obj): if isinstance(obj, set): return list(obj) raise TypeError assert orjson.dumps({1, 2}, default=default) == b"[1,2]" orjson-3.9.15/test/test_dict.py000066400000000000000000000125141456615046100164510ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson class TestDict: def test_dict(self): """ dict """ obj = {"key": "value"} ref = '{"key":"value"}' assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == obj def test_dict_duplicate_loads(self): assert orjson.loads(b'{"1":true,"1":false}') == {"1": False} def test_dict_empty(self): obj = [{"key": [{}] * 4096}] * 4096 # type:ignore assert orjson.loads(orjson.dumps(obj)) == obj def test_dict_large_dict(self): """ dict with >512 keys """ obj = {"key_%s" % idx: [{}, {"a": [{}, {}, {}]}, {}] for idx in range(513)} assert len(obj) == 513 assert orjson.loads(orjson.dumps(obj)) == obj def test_dict_large_4096(self): """ dict with >4096 keys """ obj = {"key_%s" % idx: "value_%s" % idx for idx in range(4097)} assert len(obj) == 4097 assert orjson.loads(orjson.dumps(obj)) == obj def test_dict_large_65536(self): """ dict with >65536 keys """ obj = {"key_%s" % idx: "value_%s" % idx for idx in range(65537)} assert len(obj) == 65537 assert orjson.loads(orjson.dumps(obj)) == obj def test_dict_large_keys(self): """ dict with keys too large to cache """ obj = { "keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey": "value" } ref = '{"keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey":"value"}' assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == obj def test_dict_unicode(self): """ dict unicode keys """ obj = {"🐈": "value"} ref = b'{"\xf0\x9f\x90\x88":"value"}' assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj assert orjson.loads(ref)["🐈"] == "value" def test_dict_invalid_key_dumps(self): """ dict invalid key dumps() """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps({1: "value"}) with pytest.raises(orjson.JSONEncodeError): orjson.dumps({b"key": "value"}) def test_dict_invalid_key_loads(self): """ dict invalid key loads() """ with pytest.raises(orjson.JSONDecodeError): orjson.loads('{1:"value"}') with pytest.raises(orjson.JSONDecodeError): orjson.loads('{{"a":true}:true}') def test_dict_similar_keys(self): """ loads() similar keys This was a regression in 3.4.2 caused by using the implementation in wy instead of wyhash. """ assert orjson.loads( '{"cf_status_firefox67": "---", "cf_status_firefox57": "verified"}' ) == {"cf_status_firefox57": "verified", "cf_status_firefox67": "---"} def test_dict_pop_replace_first(self): "Test pop and replace a first key in a dict with other keys." data = {"id": "any", "other": "any"} data.pop("id") assert orjson.dumps(data) == b'{"other":"any"}' data["id"] = "new" assert orjson.dumps(data) == b'{"other":"any","id":"new"}' def test_dict_pop_replace_last(self): "Test pop and replace a last key in a dict with other keys." data = {"other": "any", "id": "any"} data.pop("id") assert orjson.dumps(data) == b'{"other":"any"}' data["id"] = "new" assert orjson.dumps(data) == b'{"other":"any","id":"new"}' def test_dict_pop(self): "Test pop and replace a key in a dict with no other keys." data = {"id": "any"} data.pop("id") assert orjson.dumps(data) == b"{}" data["id"] = "new" assert orjson.dumps(data) == b'{"id":"new"}' def test_in_place(self): "Mutate dict in-place" data = {"id": "any", "static": "msg"} data["id"] = "new" assert orjson.dumps(data) == b'{"id":"new","static":"msg"}' def test_dict_0xff(self): "dk_size <= 0xff" data = {str(idx): idx for idx in range(0, 0xFF)} data.pop("112") data["112"] = 1 data["113"] = 2 assert orjson.loads(orjson.dumps(data)) == data def test_dict_0xff_repeated(self): "dk_size <= 0xff repeated" for _ in range(0, 100): data = {str(idx): idx for idx in range(0, 0xFF)} data.pop("112") data["112"] = 1 data["113"] = 2 assert orjson.loads(orjson.dumps(data)) == data def test_dict_0xffff(self): "dk_size <= 0xffff" data = {str(idx): idx for idx in range(0, 0xFFFF)} data.pop("112") data["112"] = 1 data["113"] = 2 assert orjson.loads(orjson.dumps(data)) == data def test_dict_0xffff_repeated(self): "dk_size <= 0xffff repeated" for _ in range(0, 100): data = {str(idx): idx for idx in range(0, 0xFFFF)} data.pop("112") data["112"] = 1 data["113"] = 2 assert orjson.loads(orjson.dumps(data)) == data def test_dict_dict(self): class C: def __init__(self): self.a = 0 self.b = 1 assert orjson.dumps(C().__dict__) == b'{"a":0,"b":1}' orjson-3.9.15/test/test_enum.py000066400000000000000000000051061456615046100164710ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import datetime import enum import pytest import orjson class StrEnum(str, enum.Enum): AAA = "aaa" class IntEnum(int, enum.Enum): ONE = 1 class IntEnumEnum(enum.IntEnum): ONE = 1 class IntFlagEnum(enum.IntFlag): ONE = 1 class FlagEnum(enum.Flag): ONE = 1 class AutoEnum(enum.auto): A = "a" class FloatEnum(float, enum.Enum): ONE = 1.1 class Custom: def __init__(self, val): self.val = val def default(obj): if isinstance(obj, Custom): return obj.val raise TypeError class UnspecifiedEnum(enum.Enum): A = "a" B = 1 C = FloatEnum.ONE D = {"d": IntEnum.ONE} E = Custom("c") F = datetime.datetime(1970, 1, 1) class TestEnum: def test_cannot_subclass(self): """ enum.Enum cannot be subclassed obj->ob_type->ob_base will always be enum.EnumMeta """ with pytest.raises(TypeError): class Subclass(StrEnum): # type: ignore B = "b" def test_arbitrary_enum(self): assert orjson.dumps(UnspecifiedEnum.A) == b'"a"' assert orjson.dumps(UnspecifiedEnum.B) == b"1" assert orjson.dumps(UnspecifiedEnum.C) == b"1.1" assert orjson.dumps(UnspecifiedEnum.D) == b'{"d":1}' def test_custom_enum(self): assert orjson.dumps(UnspecifiedEnum.E, default=default) == b'"c"' def test_enum_options(self): assert ( orjson.dumps(UnspecifiedEnum.F, option=orjson.OPT_NAIVE_UTC) == b'"1970-01-01T00:00:00+00:00"' ) def test_int_enum(self): assert orjson.dumps(IntEnum.ONE) == b"1" def test_intenum_enum(self): assert orjson.dumps(IntEnumEnum.ONE) == b"1" def test_intflag_enum(self): assert orjson.dumps(IntFlagEnum.ONE) == b"1" def test_flag_enum(self): assert orjson.dumps(FlagEnum.ONE) == b"1" def test_auto_enum(self): assert orjson.dumps(AutoEnum.A) == b'"a"' def test_float_enum(self): assert orjson.dumps(FloatEnum.ONE) == b"1.1" def test_str_enum(self): assert orjson.dumps(StrEnum.AAA) == b'"aaa"' def test_bool_enum(self): with pytest.raises(TypeError): class BoolEnum(bool, enum.Enum): # type: ignore TRUE = True def test_non_str_keys_enum(self): assert ( orjson.dumps({StrEnum.AAA: 1}, option=orjson.OPT_NON_STR_KEYS) == b'{"aaa":1}' ) assert ( orjson.dumps({IntEnum.ONE: 1}, option=orjson.OPT_NON_STR_KEYS) == b'{"1":1}' ) orjson-3.9.15/test/test_error.py000066400000000000000000000125041456615046100166560ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import json import pytest import orjson from .util import read_fixture_str ASCII_TEST = b"""\ { "a": "qwe", "b": "qweqwe", "c": "qweq", "d: "qwe" } """ MULTILINE_EMOJI = """[ "😊", "a" """ class TestJsonDecodeError: def _get_error_infos(self, json_decode_error_exc_info): return { k: v for k, v in json_decode_error_exc_info.value.__dict__.items() if k in ("pos", "lineno", "colno") } def _test(self, data, expected_err_infos): with pytest.raises(json.decoder.JSONDecodeError) as json_exc_info: json.loads(data) with pytest.raises(json.decoder.JSONDecodeError) as orjson_exc_info: orjson.loads(data) assert ( self._get_error_infos(json_exc_info) == self._get_error_infos(orjson_exc_info) == expected_err_infos ) def test_empty(self): with pytest.raises(orjson.JSONDecodeError) as json_exc_info: orjson.loads("") assert str(json_exc_info.value).startswith( "Input is a zero-length, empty document:" ) def test_ascii(self): self._test( ASCII_TEST, {"pos": 55, "lineno": 5, "colno": 8}, ) def test_latin1(self): self._test( """["üýþÿ", "a" """, {"pos": 13, "lineno": 1, "colno": 14}, ) def test_two_byte_str(self): self._test( """["東京", "a" """, {"pos": 11, "lineno": 1, "colno": 12}, ) def test_two_byte_bytes(self): self._test( b'["\xe6\x9d\xb1\xe4\xba\xac", "a" ', {"pos": 11, "lineno": 1, "colno": 12}, ) def test_four_byte(self): self._test( MULTILINE_EMOJI, {"pos": 19, "lineno": 4, "colno": 1}, ) def test_tab(self): data = read_fixture_str("fail26.json", "jsonchecker") with pytest.raises(json.decoder.JSONDecodeError) as json_exc_info: json.loads(data) assert self._get_error_infos(json_exc_info) == { "pos": 5, "lineno": 1, "colno": 6, } with pytest.raises(json.decoder.JSONDecodeError) as json_exc_info: orjson.loads(data) assert self._get_error_infos(json_exc_info) == { "pos": 6, "lineno": 1, "colno": 7, } class Custom: pass class CustomException(Exception): pass def default_typeerror(obj): raise TypeError def default_notimplementederror(obj): raise NotImplementedError def default_systemerror(obj): raise SystemError def default_importerror(obj): import doesnotexist assert doesnotexist CUSTOM_ERROR_MESSAGE = "zxc" def default_customerror(obj): raise CustomException(CUSTOM_ERROR_MESSAGE) class TestJsonEncodeError: def test_dumps_arg(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps() # type: ignore assert exc_info.type == orjson.JSONEncodeError assert ( str(exc_info.value) == "dumps() missing 1 required positional argument: 'obj'" ) assert exc_info.value.__cause__ is None def test_dumps_chain_none(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(Custom()) assert exc_info.type == orjson.JSONEncodeError assert str(exc_info.value) == "Type is not JSON serializable: Custom" assert exc_info.value.__cause__ is None def test_dumps_chain_u64(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps([18446744073709551615, Custom()]) assert exc_info.type == orjson.JSONEncodeError assert exc_info.value.__cause__ is None def test_dumps_chain_default_typeerror(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(Custom(), default=default_typeerror) assert exc_info.type == orjson.JSONEncodeError assert isinstance(exc_info.value.__cause__, TypeError) def test_dumps_chain_default_systemerror(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(Custom(), default=default_systemerror) assert exc_info.type == orjson.JSONEncodeError assert isinstance(exc_info.value.__cause__, SystemError) def test_dumps_chain_default_importerror(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(Custom(), default=default_importerror) assert exc_info.type == orjson.JSONEncodeError assert isinstance(exc_info.value.__cause__, ImportError) def test_dumps_chain_default_customerror(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(Custom(), default=default_customerror) assert exc_info.type == orjson.JSONEncodeError assert isinstance(exc_info.value.__cause__, CustomException) assert str(exc_info.value.__cause__) == CUSTOM_ERROR_MESSAGE def test_dumps_normalize_exception(self): with pytest.raises(orjson.JSONEncodeError) as exc_info: orjson.dumps(10**60) assert exc_info.type == orjson.JSONEncodeError assert isinstance(exc_info.value.__cause__, OverflowError) orjson-3.9.15/test/test_fake.py000066400000000000000000000021351456615046100164320ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import random import pytest import orjson try: from faker import Faker except ImportError: Faker = None # type: ignore NUM_LOOPS = 10 NUM_SHUFFLES = 10 NUM_ENTRIES = 250 FAKER_LOCALES = [ "ar_AA", "fi_FI", "fil_PH", "he_IL", "ja_JP", "th_TH", "tr_TR", "uk_UA", "vi_VN", ] class TestFaker: @pytest.mark.skipif(Faker is None, reason="faker not available") def test_faker(self): fake = Faker(FAKER_LOCALES) profile_keys = tuple( set(fake.profile().keys()) - {"birthdate", "current_location"} ) for _ in range(0, NUM_LOOPS): data = [ { "person": fake.profile(profile_keys), "emoji": fake.emoji(), "text": fake.paragraphs(), } for _ in range(0, NUM_ENTRIES) ] for _ in range(0, NUM_SHUFFLES): random.shuffle(data) output = orjson.dumps(data) assert orjson.loads(output) == data orjson-3.9.15/test/test_fixture.py000066400000000000000000000027241456615046100172160ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson from .util import read_fixture_bytes, read_fixture_str class TestFixture: def test_twitter(self): """ loads(),dumps() twitter.json """ val = read_fixture_str("twitter.json.xz") read = orjson.loads(val) assert orjson.loads(orjson.dumps(read)) == read def test_canada(self): """ loads(), dumps() canada.json """ val = read_fixture_str("canada.json.xz") read = orjson.loads(val) assert orjson.loads(orjson.dumps(read)) == read def test_citm_catalog(self): """ loads(), dumps() citm_catalog.json """ val = read_fixture_str("citm_catalog.json.xz") read = orjson.loads(val) assert orjson.loads(orjson.dumps(read)) == read def test_github(self): """ loads(), dumps() github.json """ val = read_fixture_str("github.json.xz") read = orjson.loads(val) assert orjson.loads(orjson.dumps(read)) == read def test_blns(self): """ loads() blns.json JSONDecodeError https://github.com/minimaxir/big-list-of-naughty-strings """ val = read_fixture_bytes("blns.txt.xz") for line in val.split(b"\n"): if line and not line.startswith(b"#"): with pytest.raises(orjson.JSONDecodeError): _ = orjson.loads(b'"' + val + b'"') orjson-3.9.15/test/test_fragment.py000066400000000000000000001170031456615046100173300ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson try: import pandas except ImportError: pandas = None # type: ignore from .util import read_fixture_bytes class TestFragment: def test_fragment_fragment_eq(self): assert orjson.Fragment(b"{}") != orjson.Fragment(b"{}") def test_fragment_fragment_not_mut(self): fragment = orjson.Fragment(b"{}") with pytest.raises(AttributeError): fragment.contents = b"[]" assert orjson.dumps(fragment) == b"{}" def test_fragment_repr(self): assert repr(orjson.Fragment(b"{}")).startswith("?","hex":"ģ䕧覫췯ꯍ\uef4a","true":true,"false":false,"null":null,"array":[],"object":{},"address":"50 St. James Street","url":"http://www.JSON.org/","comment":"// /* */":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\\"object with 1 member\\":[\\"array with 1 element\\"]}","quotes":"" \\" %22 0x22 034 "","/\\\\\\"쫾몾ꮘﳞ볚\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?":"A key can be any string"},0.5,98.6,99.44,1066,10.0,1.0,0.1,1.0,2.0,2.0,"rosebud"]'.encode() class TestJsonChecker: def _run_fail_json(self, filename, exc=orjson.JSONDecodeError): data = read_fixture_str(filename, "jsonchecker") pytest.raises(exc, orjson.loads, data) def _run_pass_json(self, filename, match=""): data = read_fixture_str(filename, "jsonchecker") assert orjson.dumps(orjson.loads(data)) == match def test_fail01(self): """ fail01.json """ self._run_pass_json( "fail01.json", b'"A JSON payload should be an object or array, not a string."', ) def test_fail02(self): """ fail02.json """ self._run_fail_json("fail02.json", orjson.JSONDecodeError) # EOF def test_fail03(self): """ fail03.json """ self._run_fail_json("fail03.json") def test_fail04(self): """ fail04.json """ self._run_fail_json("fail04.json") def test_fail05(self): """ fail05.json """ self._run_fail_json("fail05.json") def test_fail06(self): """ fail06.json """ self._run_fail_json("fail06.json") def test_fail07(self): """ fail07.json """ self._run_fail_json("fail07.json") def test_fail08(self): """ fail08.json """ self._run_fail_json("fail08.json") def test_fail09(self): """ fail09.json """ self._run_fail_json("fail09.json") def test_fail10(self): """ fail10.json """ self._run_fail_json("fail10.json") def test_fail11(self): """ fail11.json """ self._run_fail_json("fail11.json") def test_fail12(self): """ fail12.json """ self._run_fail_json("fail12.json") def test_fail13(self): """ fail13.json """ self._run_fail_json("fail13.json") def test_fail14(self): """ fail14.json """ self._run_fail_json("fail14.json") def test_fail15(self): """ fail15.json """ self._run_fail_json("fail15.json") def test_fail16(self): """ fail16.json """ self._run_fail_json("fail16.json") def test_fail17(self): """ fail17.json """ self._run_fail_json("fail17.json") def test_fail18(self): """ fail18.json """ self._run_pass_json( "fail18.json", b'[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]' ) def test_fail19(self): """ fail19.json """ self._run_fail_json("fail19.json") def test_fail20(self): """ fail20.json """ self._run_fail_json("fail20.json") def test_fail21(self): """ fail21.json """ self._run_fail_json("fail21.json") def test_fail22(self): """ fail22.json """ self._run_fail_json("fail22.json") def test_fail23(self): """ fail23.json """ self._run_fail_json("fail23.json") def test_fail24(self): """ fail24.json """ self._run_fail_json("fail24.json") def test_fail25(self): """ fail25.json """ self._run_fail_json("fail25.json") def test_fail26(self): """ fail26.json """ self._run_fail_json("fail26.json") def test_fail27(self): """ fail27.json """ self._run_fail_json("fail27.json") def test_fail28(self): """ fail28.json """ self._run_fail_json("fail28.json") def test_fail29(self): """ fail29.json """ self._run_fail_json("fail29.json") def test_fail30(self): """ fail30.json """ self._run_fail_json("fail30.json") def test_fail31(self): """ fail31.json """ self._run_fail_json("fail31.json") def test_fail32(self): """ fail32.json """ self._run_fail_json("fail32.json", orjson.JSONDecodeError) # EOF def test_fail33(self): """ fail33.json """ self._run_fail_json("fail33.json") def test_pass01(self): """ pass01.json """ self._run_pass_json("pass01.json", PATTERN_1) def test_pass02(self): """ pass02.json """ self._run_pass_json( "pass02.json", b'[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]' ) def test_pass03(self): """ pass03.json """ self._run_pass_json( "pass03.json", b'{"JSON Test Pattern pass3":{"The outermost value":"must be ' b'an object or array.","In this test":"It is an object."}}', ) orjson-3.9.15/test/test_memory.py000066400000000000000000000202441456615046100170350ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import dataclasses import datetime import gc import random from typing import List try: import pytz except ImportError: pytz = None # type: ignore try: import psutil except ImportError: psutil = None # type: ignore import pytest import orjson try: import numpy except ImportError: numpy = None # type: ignore try: import pandas except ImportError: pandas = None # type: ignore FIXTURE = '{"a":[81891289, 8919812.190129012], "b": false, "c": null, "d": "東京"}' def default(obj): return str(obj) @dataclasses.dataclass class Member: id: int active: bool @dataclasses.dataclass class Object: id: int updated_at: datetime.datetime name: str members: List[Member] DATACLASS_FIXTURE = [ Object( i, datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=random.randint(0, 10000)), str(i) * 3, [Member(j, True) for j in range(0, 10)], ) for i in range(100000, 101000) ] MAX_INCREASE = 4194304 # 4MiB class Unsupported: pass class TestMemory: @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_loads(self): """ loads() memory leak """ proc = psutil.Process() gc.collect() val = orjson.loads(FIXTURE) assert val mem = proc.memory_info().rss for _ in range(10000): val = orjson.loads(FIXTURE) assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_loads_memoryview(self): """ loads() memory leak using memoryview """ proc = psutil.Process() gc.collect() fixture = FIXTURE.encode("utf-8") val = orjson.loads(fixture) assert val mem = proc.memory_info().rss for _ in range(10000): val = orjson.loads(memoryview(fixture)) assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_dumps(self): """ dumps() memory leak """ proc = psutil.Process() gc.collect() fixture = orjson.loads(FIXTURE) val = orjson.dumps(fixture) assert val mem = proc.memory_info().rss for _ in range(10000): val = orjson.dumps(fixture) assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_loads_exc(self): """ loads() memory leak exception without a GC pause """ proc = psutil.Process() gc.disable() mem = proc.memory_info().rss n = 10000 i = 0 for _ in range(n): try: orjson.loads("") except orjson.JSONDecodeError: i += 1 assert n == i assert proc.memory_info().rss <= mem + MAX_INCREASE gc.enable() @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_dumps_exc(self): """ dumps() memory leak exception without a GC pause """ proc = psutil.Process() gc.disable() data = Unsupported() mem = proc.memory_info().rss n = 10000 i = 0 for _ in range(n): try: orjson.dumps(data) except orjson.JSONEncodeError: i += 1 assert n == i assert proc.memory_info().rss <= mem + MAX_INCREASE gc.enable() @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_dumps_default(self): """ dumps() default memory leak """ proc = psutil.Process() gc.collect() fixture = orjson.loads(FIXTURE) class Custom: def __init__(self, name): self.name = name def __str__(self): return f"{self.__class__.__name__}({self.name})" fixture["custom"] = Custom("orjson") val = orjson.dumps(fixture, default=default) mem = proc.memory_info().rss for _ in range(10000): val = orjson.dumps(fixture, default=default) assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_dumps_dataclass(self): """ dumps() dataclass memory leak """ proc = psutil.Process() gc.collect() val = orjson.dumps(DATACLASS_FIXTURE) assert val mem = proc.memory_info().rss for _ in range(100): val = orjson.dumps(DATACLASS_FIXTURE) assert val assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif( psutil is None or pytz is None, reason="psutil not installed", ) def test_memory_dumps_pytz_tzinfo(self): """ dumps() pytz tzinfo memory leak """ proc = psutil.Process() gc.collect() dt = datetime.datetime.now() val = orjson.dumps(pytz.UTC.localize(dt)) assert val mem = proc.memory_info().rss for _ in range(50000): val = orjson.dumps(pytz.UTC.localize(dt)) assert val assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_loads_keys(self): """ loads() memory leak with number of keys causing cache eviction """ proc = psutil.Process() gc.collect() fixture = {"key_%s" % idx: "value" for idx in range(1024)} assert len(fixture) == 1024 val = orjson.dumps(fixture) loaded = orjson.loads(val) assert loaded mem = proc.memory_info().rss for _ in range(100): loaded = orjson.loads(val) assert loaded gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") @pytest.mark.skipif(numpy is None, reason="numpy is not installed") def test_memory_dumps_numpy(self): """ dumps() numpy memory leak """ proc = psutil.Process() gc.collect() fixture = numpy.random.rand(4, 4, 4) val = orjson.dumps(fixture, option=orjson.OPT_SERIALIZE_NUMPY) assert val mem = proc.memory_info().rss for _ in range(100): val = orjson.dumps(fixture, option=orjson.OPT_SERIALIZE_NUMPY) assert val assert val gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") @pytest.mark.skipif(pandas is None, reason="pandas is not installed") def test_memory_dumps_pandas(self): """ dumps() pandas memory leak """ proc = psutil.Process() gc.collect() numpy.random.rand(4, 4, 4) df = pandas.Series(numpy.random.rand(4, 4, 4).tolist()) val = df.map(orjson.dumps) assert not val.empty mem = proc.memory_info().rss for _ in range(100): val = df.map(orjson.dumps) assert not val.empty gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE @pytest.mark.skipif(psutil is None, reason="psutil not installed") def test_memory_dumps_fragment(self): """ dumps() Fragment memory leak """ proc = psutil.Process() gc.collect() orjson.dumps(orjson.Fragment(str(0))) mem = proc.memory_info().rss for i in range(10000): orjson.dumps(orjson.Fragment(str(i))) gc.collect() assert proc.memory_info().rss <= mem + MAX_INCREASE orjson-3.9.15/test/test_non_str_keys.py000066400000000000000000000217271456615046100202510ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import dataclasses import datetime import uuid import pytest import orjson try: import pytz except ImportError: pytz = None # type: ignore try: import numpy except ImportError: numpy = None # type: ignore class SubStr(str): pass class TestNonStrKeyTests: def test_dict_keys_duplicate(self): """ OPT_NON_STR_KEYS serializes duplicate keys """ assert ( orjson.dumps({"1": True, 1: False}, option=orjson.OPT_NON_STR_KEYS) == b'{"1":true,"1":false}' ) def test_dict_keys_int(self): assert ( orjson.dumps({1: True, 2: False}, option=orjson.OPT_NON_STR_KEYS) == b'{"1":true,"2":false}' ) def test_dict_keys_substr(self): assert ( orjson.dumps({SubStr("aaa"): True}, option=orjson.OPT_NON_STR_KEYS) == b'{"aaa":true}' ) def test_dict_keys_substr_passthrough(self): """ OPT_PASSTHROUGH_SUBCLASS does not affect OPT_NON_STR_KEYS """ assert ( orjson.dumps( {SubStr("aaa"): True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_PASSTHROUGH_SUBCLASS, ) == b'{"aaa":true}' ) def test_dict_keys_substr_invalid(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps({SubStr("\ud800"): True}, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_strict(self): """ OPT_NON_STR_KEYS does not respect OPT_STRICT_INTEGER """ assert ( orjson.dumps( {9223372036854775807: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"9223372036854775807":true}' ) def test_dict_keys_int_range_valid_i64(self): """ OPT_NON_STR_KEYS has a i64 range for int, valid """ assert ( orjson.dumps( {9223372036854775807: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"9223372036854775807":true}' ) assert ( orjson.dumps( {-9223372036854775807: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"-9223372036854775807":true}' ) assert ( orjson.dumps( {9223372036854775809: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"9223372036854775809":true}' ) def test_dict_keys_int_range_valid_u64(self): """ OPT_NON_STR_KEYS has a u64 range for int, valid """ assert ( orjson.dumps( {0: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"0":true}' ) assert ( orjson.dumps( {18446744073709551615: True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_STRICT_INTEGER, ) == b'{"18446744073709551615":true}' ) def test_dict_keys_int_range_invalid(self): """ OPT_NON_STR_KEYS has a range of i64::MIN to u64::MAX """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps({-9223372036854775809: True}, option=orjson.OPT_NON_STR_KEYS) with pytest.raises(orjson.JSONEncodeError): orjson.dumps({18446744073709551616: True}, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_float(self): assert ( orjson.dumps({1.1: True, 2.2: False}, option=orjson.OPT_NON_STR_KEYS) == b'{"1.1":true,"2.2":false}' ) def test_dict_keys_inf(self): assert ( orjson.dumps({float("Infinity"): True}, option=orjson.OPT_NON_STR_KEYS) == b'{"null":true}' ) assert ( orjson.dumps({float("-Infinity"): True}, option=orjson.OPT_NON_STR_KEYS) == b'{"null":true}' ) def test_dict_keys_nan(self): assert ( orjson.dumps({float("NaN"): True}, option=orjson.OPT_NON_STR_KEYS) == b'{"null":true}' ) def test_dict_keys_bool(self): assert ( orjson.dumps({True: True, False: False}, option=orjson.OPT_NON_STR_KEYS) == b'{"true":true,"false":false}' ) def test_dict_keys_datetime(self): assert ( orjson.dumps( {datetime.datetime(2000, 1, 1, 2, 3, 4, 123): True}, option=orjson.OPT_NON_STR_KEYS, ) == b'{"2000-01-01T02:03:04.000123":true}' ) def test_dict_keys_datetime_opt(self): assert ( orjson.dumps( {datetime.datetime(2000, 1, 1, 2, 3, 4, 123): True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_OMIT_MICROSECONDS | orjson.OPT_NAIVE_UTC | orjson.OPT_UTC_Z, ) == b'{"2000-01-01T02:03:04Z":true}' ) def test_dict_keys_datetime_passthrough(self): """ OPT_PASSTHROUGH_DATETIME does not affect OPT_NON_STR_KEYS """ assert ( orjson.dumps( {datetime.datetime(2000, 1, 1, 2, 3, 4, 123): True}, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_PASSTHROUGH_DATETIME, ) == b'{"2000-01-01T02:03:04.000123":true}' ) def test_dict_keys_uuid(self): """ OPT_NON_STR_KEYS always serializes UUID as keys """ assert ( orjson.dumps( {uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"): True}, option=orjson.OPT_NON_STR_KEYS, ) == b'{"7202d115-7ff3-4c81-a7c1-2a1f067b1ece":true}' ) def test_dict_keys_date(self): assert ( orjson.dumps( {datetime.date(1970, 1, 1): True}, option=orjson.OPT_NON_STR_KEYS ) == b'{"1970-01-01":true}' ) def test_dict_keys_time(self): assert ( orjson.dumps( {datetime.time(12, 15, 59, 111): True}, option=orjson.OPT_NON_STR_KEYS, ) == b'{"12:15:59.000111":true}' ) def test_dict_non_str_and_sort_keys(self): assert ( orjson.dumps( { "other": 1, datetime.date(1970, 1, 5): 2, datetime.date(1970, 1, 3): 3, }, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS, ) == b'{"1970-01-03":3,"1970-01-05":2,"other":1}' ) @pytest.mark.skipif(pytz is None, reason="pytz optional") def test_dict_keys_time_err(self): """ OPT_NON_STR_KEYS propagates errors in types """ val = datetime.time(12, 15, 59, 111, tzinfo=pytz.timezone("Asia/Shanghai")) with pytest.raises(orjson.JSONEncodeError): orjson.dumps({val: True}, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_str(self): assert ( orjson.dumps({"1": True}, option=orjson.OPT_NON_STR_KEYS) == b'{"1":true}' ) def test_dict_keys_type(self): class Obj: a: str val = Obj() with pytest.raises(orjson.JSONEncodeError): orjson.dumps({val: True}, option=orjson.OPT_NON_STR_KEYS) @pytest.mark.skipif(numpy is None, reason="numpy is not installed") def test_dict_keys_array(self): with pytest.raises(TypeError): {numpy.array([1, 2]): True} def test_dict_keys_dataclass(self): @dataclasses.dataclass class Dataclass: a: str with pytest.raises(TypeError): {Dataclass("a"): True} def test_dict_keys_dataclass_hash(self): @dataclasses.dataclass class Dataclass: a: str def __hash__(self): return 1 obj = {Dataclass("a"): True} with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_list(self): with pytest.raises(TypeError): {[]: True} def test_dict_keys_dict(self): with pytest.raises(TypeError): {{}: True} def test_dict_keys_tuple(self): obj = {(): True} with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_unknown(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps({frozenset(): True}, option=orjson.OPT_NON_STR_KEYS) def test_dict_keys_no_str_call(self): class Obj: a: str def __str__(self): return "Obj" val = Obj() with pytest.raises(orjson.JSONEncodeError): orjson.dumps({val: True}, option=orjson.OPT_NON_STR_KEYS) orjson-3.9.15/test/test_numpy.py000066400000000000000000000640221456615046100166770ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson try: import numpy except ImportError: numpy = None # type: ignore def numpy_default(obj): return obj.tolist() @pytest.mark.skipif(numpy is None, reason="numpy is not installed") class TestNumpy: def test_numpy_array_d1_uintp(self): low = numpy.iinfo(numpy.uintp).min high = numpy.iinfo(numpy.uintp).max assert orjson.dumps( numpy.array([low, high], numpy.uintp), option=orjson.OPT_SERIALIZE_NUMPY, ) == f"[{low},{high}]".encode("ascii") def test_numpy_array_d1_intp(self): low = numpy.iinfo(numpy.intp).min high = numpy.iinfo(numpy.intp).max assert orjson.dumps( numpy.array([low, high], numpy.intp), option=orjson.OPT_SERIALIZE_NUMPY, ) == f"[{low},{high}]".encode("ascii") def test_numpy_array_d1_i64(self): assert ( orjson.dumps( numpy.array([-9223372036854775807, 9223372036854775807], numpy.int64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[-9223372036854775807,9223372036854775807]" ) def test_numpy_array_d1_u64(self): assert ( orjson.dumps( numpy.array([0, 18446744073709551615], numpy.uint64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[0,18446744073709551615]" ) def test_numpy_array_d1_i8(self): assert ( orjson.dumps( numpy.array([-128, 127], numpy.int8), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[-128,127]" ) def test_numpy_array_d1_u8(self): assert ( orjson.dumps( numpy.array([0, 255], numpy.uint8), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[0,255]" ) def test_numpy_array_d1_i32(self): assert ( orjson.dumps( numpy.array([-2147483647, 2147483647], numpy.int32), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[-2147483647,2147483647]" ) def test_numpy_array_d1_i16(self): assert ( orjson.dumps( numpy.array([-32768, 32767], numpy.int16), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[-32768,32767]" ) def test_numpy_array_d1_u16(self): assert ( orjson.dumps( numpy.array([0, 65535], numpy.uint16), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[0,65535]" ) def test_numpy_array_d1_u32(self): assert ( orjson.dumps( numpy.array([0, 4294967295], numpy.uint32), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[0,4294967295]" ) def test_numpy_array_d1_f32(self): assert ( orjson.dumps( numpy.array([1.0, 3.4028235e38], numpy.float32), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[1.0,3.4028235e38]" ) def test_numpy_array_d1_f64(self): assert ( orjson.dumps( numpy.array([1.0, 1.7976931348623157e308], numpy.float64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[1.0,1.7976931348623157e308]" ) def test_numpy_array_d1_bool(self): assert ( orjson.dumps( numpy.array([True, False, False, True]), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[true,false,false,true]" ) def test_numpy_array_d1_datetime64_years(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("1"), numpy.datetime64("970"), numpy.datetime64("1920"), numpy.datetime64("1971"), numpy.datetime64("2021"), numpy.datetime64("2022"), numpy.datetime64("2023"), numpy.datetime64("9999"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["0001-01-01T00:00:00","0970-01-01T00:00:00","1920-01-01T00:00:00","1971-01-01T00:00:00","2021-01-01T00:00:00","2022-01-01T00:00:00","2023-01-01T00:00:00","9999-01-01T00:00:00"]' ) def test_numpy_array_d1_datetime64_months(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01"), numpy.datetime64("2022-01"), numpy.datetime64("2023-01"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2022-01-01T00:00:00","2023-01-01T00:00:00"]' ) def test_numpy_array_d1_datetime64_days(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01"), numpy.datetime64("2021-01-01"), numpy.datetime64("2021-01-01"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:00:00","2021-01-01T00:00:00"]' ) def test_numpy_array_d1_datetime64_hours(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00"), numpy.datetime64("2021-01-01T01"), numpy.datetime64("2021-01-01T02"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T01:00:00","2021-01-01T02:00:00"]' ) def test_numpy_array_d1_datetime64_minutes(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00"), numpy.datetime64("2021-01-01T00:01"), numpy.datetime64("2021-01-01T00:02"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:01:00","2021-01-01T00:02:00"]' ) def test_numpy_array_d1_datetime64_seconds(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00:00"), numpy.datetime64("2021-01-01T00:00:01"), numpy.datetime64("2021-01-01T00:00:02"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:00:01","2021-01-01T00:00:02"]' ) def test_numpy_array_d1_datetime64_milliseconds(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00:00"), numpy.datetime64("2021-01-01T00:00:00.172"), numpy.datetime64("2021-01-01T00:00:00.567"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:00:00.172000","2021-01-01T00:00:00.567000"]' ) def test_numpy_array_d1_datetime64_microseconds(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00:00"), numpy.datetime64("2021-01-01T00:00:00.172"), numpy.datetime64("2021-01-01T00:00:00.567891"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:00:00.172000","2021-01-01T00:00:00.567891"]' ) def test_numpy_array_d1_datetime64_nanoseconds(self): assert ( orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00:00"), numpy.datetime64("2021-01-01T00:00:00.172"), numpy.datetime64("2021-01-01T00:00:00.567891234"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b'["2021-01-01T00:00:00","2021-01-01T00:00:00.172000","2021-01-01T00:00:00.567891"]' ) def test_numpy_array_d1_datetime64_picoseconds(self): try: orjson.dumps( numpy.array( [ numpy.datetime64("2021-01-01T00:00:00"), numpy.datetime64("2021-01-01T00:00:00.172"), numpy.datetime64("2021-01-01T00:00:00.567891234567"), ] ), option=orjson.OPT_SERIALIZE_NUMPY, ) assert False except TypeError as exc: assert str(exc) == "unsupported numpy.datetime64 unit: picoseconds" def test_numpy_array_d2_i64(self): assert ( orjson.dumps( numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[1,2,3],[4,5,6]]" ) def test_numpy_array_d2_f64(self): assert ( orjson.dumps( numpy.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], numpy.float64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[1.0,2.0,3.0],[4.0,5.0,6.0]]" ) def test_numpy_array_d3_i8(self): assert ( orjson.dumps( numpy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], numpy.int8), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1,2],[3,4]],[[5,6],[7,8]]]" ) def test_numpy_array_d3_u8(self): assert ( orjson.dumps( numpy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], numpy.uint8), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1,2],[3,4]],[[5,6],[7,8]]]" ) def test_numpy_array_d3_i32(self): assert ( orjson.dumps( numpy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], numpy.int32), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1,2],[3,4]],[[5,6],[7,8]]]" ) def test_numpy_array_d3_i64(self): assert ( orjson.dumps( numpy.array([[[1, 2], [3, 4], [5, 6], [7, 8]]], numpy.int64), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1,2],[3,4],[5,6],[7,8]]]" ) def test_numpy_array_d3_f64(self): assert ( orjson.dumps( numpy.array( [[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], numpy.float64 ), option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1.0,2.0],[3.0,4.0]],[[5.0,6.0],[7.0,8.0]]]" ) def test_numpy_array_fortran(self): array = numpy.array([[1, 2], [3, 4]], order="F") assert array.flags["F_CONTIGUOUS"] is True with pytest.raises(orjson.JSONEncodeError): orjson.dumps(array, option=orjson.OPT_SERIALIZE_NUMPY) assert orjson.dumps( array, default=numpy_default, option=orjson.OPT_SERIALIZE_NUMPY ) == orjson.dumps(array.tolist()) def test_numpy_array_non_contiguous_message(self): array = numpy.array([[1, 2], [3, 4]], order="F") assert array.flags["F_CONTIGUOUS"] is True try: orjson.dumps(array, option=orjson.OPT_SERIALIZE_NUMPY) assert False except TypeError as exc: assert ( str(exc) == "numpy array is not C contiguous; use ndarray.tolist() in default" ) def test_numpy_array_unsupported_dtype(self): array = numpy.array([[1, 2], [3, 4]], numpy.float16) # type: ignore with pytest.raises(orjson.JSONEncodeError) as cm: orjson.dumps(array, option=orjson.OPT_SERIALIZE_NUMPY) assert "unsupported datatype in numpy array" in str(cm) assert orjson.dumps( array, default=numpy_default, option=orjson.OPT_SERIALIZE_NUMPY ) == orjson.dumps(array.tolist()) def test_numpy_array_d1(self): array = numpy.array([1]) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_d2(self): array = numpy.array([[1]]) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_d3(self): array = numpy.array([[[1]]]) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_d4(self): array = numpy.array([[[[1]]]]) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_4_stride(self): array = numpy.random.rand(4, 4, 4, 4) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_dimension_zero(self): array = numpy.array(0) assert array.ndim == 0 with pytest.raises(orjson.JSONEncodeError): orjson.dumps(array, option=orjson.OPT_SERIALIZE_NUMPY) array = numpy.empty((0, 4, 2)) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) array = numpy.empty((4, 0, 2)) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) array = numpy.empty((2, 4, 0)) assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_array_dimension_max(self): array = numpy.random.rand( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ) assert array.ndim == 32 assert ( orjson.loads( orjson.dumps( array, option=orjson.OPT_SERIALIZE_NUMPY, ) ) == array.tolist() ) def test_numpy_scalar_int8(self): assert orjson.dumps(numpy.int8(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps(numpy.int8(127), option=orjson.OPT_SERIALIZE_NUMPY) == b"127" ) assert ( orjson.dumps(numpy.int8(-128), option=orjson.OPT_SERIALIZE_NUMPY) == b"-128" ) def test_numpy_scalar_int16(self): assert orjson.dumps(numpy.int16(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps(numpy.int16(32767), option=orjson.OPT_SERIALIZE_NUMPY) == b"32767" ) assert ( orjson.dumps(numpy.int16(-32768), option=orjson.OPT_SERIALIZE_NUMPY) == b"-32768" ) def test_numpy_scalar_int32(self): assert orjson.dumps(numpy.int32(1), option=orjson.OPT_SERIALIZE_NUMPY) == b"1" assert ( orjson.dumps(numpy.int32(2147483647), option=orjson.OPT_SERIALIZE_NUMPY) == b"2147483647" ) assert ( orjson.dumps(numpy.int32(-2147483648), option=orjson.OPT_SERIALIZE_NUMPY) == b"-2147483648" ) def test_numpy_scalar_int64(self): assert ( orjson.dumps( numpy.int64(-9223372036854775808), option=orjson.OPT_SERIALIZE_NUMPY ) == b"-9223372036854775808" ) assert ( orjson.dumps( numpy.int64(9223372036854775807), option=orjson.OPT_SERIALIZE_NUMPY ) == b"9223372036854775807" ) def test_numpy_scalar_uint8(self): assert orjson.dumps(numpy.uint8(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps(numpy.uint8(255), option=orjson.OPT_SERIALIZE_NUMPY) == b"255" ) def test_numpy_scalar_uint16(self): assert orjson.dumps(numpy.uint16(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps(numpy.uint16(65535), option=orjson.OPT_SERIALIZE_NUMPY) == b"65535" ) def test_numpy_scalar_uint32(self): assert orjson.dumps(numpy.uint32(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps(numpy.uint32(4294967295), option=orjson.OPT_SERIALIZE_NUMPY) == b"4294967295" ) def test_numpy_scalar_uint64(self): assert orjson.dumps(numpy.uint64(0), option=orjson.OPT_SERIALIZE_NUMPY) == b"0" assert ( orjson.dumps( numpy.uint64(18446744073709551615), option=orjson.OPT_SERIALIZE_NUMPY ) == b"18446744073709551615" ) def test_numpy_scalar_float32(self): assert ( orjson.dumps(numpy.float32(1.0), option=orjson.OPT_SERIALIZE_NUMPY) == b"1.0" ) def test_numpy_scalar_float64(self): assert ( orjson.dumps(numpy.float64(123.123), option=orjson.OPT_SERIALIZE_NUMPY) == b"123.123" ) def test_numpy_bool(self): assert ( orjson.dumps( {"a": numpy.bool_(True), "b": numpy.bool_(False)}, option=orjson.OPT_SERIALIZE_NUMPY, ) == b'{"a":true,"b":false}' ) def test_numpy_datetime(self): assert ( orjson.dumps( { "year": numpy.datetime64("2021"), "month": numpy.datetime64("2021-01"), "day": numpy.datetime64("2021-01-01"), "hour": numpy.datetime64("2021-01-01T00"), "minute": numpy.datetime64("2021-01-01T00:00"), "second": numpy.datetime64("2021-01-01T00:00:00"), "milli": numpy.datetime64("2021-01-01T00:00:00.172"), "micro": numpy.datetime64("2021-01-01T00:00:00.172576"), "nano": numpy.datetime64("2021-01-01T00:00:00.172576789"), }, option=orjson.OPT_SERIALIZE_NUMPY, ) == b'{"year":"2021-01-01T00:00:00","month":"2021-01-01T00:00:00","day":"2021-01-01T00:00:00","hour":"2021-01-01T00:00:00","minute":"2021-01-01T00:00:00","second":"2021-01-01T00:00:00","milli":"2021-01-01T00:00:00.172000","micro":"2021-01-01T00:00:00.172576","nano":"2021-01-01T00:00:00.172576"}' ) def test_numpy_datetime_naive_utc(self): assert ( orjson.dumps( { "year": numpy.datetime64("2021"), "month": numpy.datetime64("2021-01"), "day": numpy.datetime64("2021-01-01"), "hour": numpy.datetime64("2021-01-01T00"), "minute": numpy.datetime64("2021-01-01T00:00"), "second": numpy.datetime64("2021-01-01T00:00:00"), "milli": numpy.datetime64("2021-01-01T00:00:00.172"), "micro": numpy.datetime64("2021-01-01T00:00:00.172576"), "nano": numpy.datetime64("2021-01-01T00:00:00.172576789"), }, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_NAIVE_UTC, ) == b'{"year":"2021-01-01T00:00:00+00:00","month":"2021-01-01T00:00:00+00:00","day":"2021-01-01T00:00:00+00:00","hour":"2021-01-01T00:00:00+00:00","minute":"2021-01-01T00:00:00+00:00","second":"2021-01-01T00:00:00+00:00","milli":"2021-01-01T00:00:00.172000+00:00","micro":"2021-01-01T00:00:00.172576+00:00","nano":"2021-01-01T00:00:00.172576+00:00"}' ) def test_numpy_datetime_naive_utc_utc_z(self): assert ( orjson.dumps( { "year": numpy.datetime64("2021"), "month": numpy.datetime64("2021-01"), "day": numpy.datetime64("2021-01-01"), "hour": numpy.datetime64("2021-01-01T00"), "minute": numpy.datetime64("2021-01-01T00:00"), "second": numpy.datetime64("2021-01-01T00:00:00"), "milli": numpy.datetime64("2021-01-01T00:00:00.172"), "micro": numpy.datetime64("2021-01-01T00:00:00.172576"), "nano": numpy.datetime64("2021-01-01T00:00:00.172576789"), }, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_NAIVE_UTC | orjson.OPT_UTC_Z, ) == b'{"year":"2021-01-01T00:00:00Z","month":"2021-01-01T00:00:00Z","day":"2021-01-01T00:00:00Z","hour":"2021-01-01T00:00:00Z","minute":"2021-01-01T00:00:00Z","second":"2021-01-01T00:00:00Z","milli":"2021-01-01T00:00:00.172000Z","micro":"2021-01-01T00:00:00.172576Z","nano":"2021-01-01T00:00:00.172576Z"}' ) def test_numpy_datetime_omit_microseconds(self): assert ( orjson.dumps( { "year": numpy.datetime64("2021"), "month": numpy.datetime64("2021-01"), "day": numpy.datetime64("2021-01-01"), "hour": numpy.datetime64("2021-01-01T00"), "minute": numpy.datetime64("2021-01-01T00:00"), "second": numpy.datetime64("2021-01-01T00:00:00"), "milli": numpy.datetime64("2021-01-01T00:00:00.172"), "micro": numpy.datetime64("2021-01-01T00:00:00.172576"), "nano": numpy.datetime64("2021-01-01T00:00:00.172576789"), }, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_OMIT_MICROSECONDS, ) == b'{"year":"2021-01-01T00:00:00","month":"2021-01-01T00:00:00","day":"2021-01-01T00:00:00","hour":"2021-01-01T00:00:00","minute":"2021-01-01T00:00:00","second":"2021-01-01T00:00:00","milli":"2021-01-01T00:00:00","micro":"2021-01-01T00:00:00","nano":"2021-01-01T00:00:00"}' ) def test_numpy_datetime_nat(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(numpy.datetime64("NaT"), option=orjson.OPT_SERIALIZE_NUMPY) with pytest.raises(orjson.JSONEncodeError): orjson.dumps([numpy.datetime64("NaT")], option=orjson.OPT_SERIALIZE_NUMPY) def test_numpy_repeated(self): data = numpy.array([[[1, 2], [3, 4], [5, 6], [7, 8]]], numpy.int64) # type: ignore for _ in range(0, 3): assert ( orjson.dumps( data, option=orjson.OPT_SERIALIZE_NUMPY, ) == b"[[[1,2],[3,4],[5,6],[7,8]]]" ) @pytest.mark.skipif(numpy is None, reason="numpy is not installed") class TestNumpyEquivalence: def _test(self, obj): assert orjson.dumps(obj, option=orjson.OPT_SERIALIZE_NUMPY) == orjson.dumps( obj.tolist() ) def test_numpy_uint8(self): self._test(numpy.array([0, 255], numpy.uint8)) def test_numpy_uint16(self): self._test(numpy.array([0, 65535], numpy.uint16)) def test_numpy_uint32(self): self._test(numpy.array([0, 4294967295], numpy.uint32)) def test_numpy_uint64(self): self._test(numpy.array([0, 18446744073709551615], numpy.uint64)) def test_numpy_int8(self): self._test(numpy.array([-128, 127], numpy.int8)) def test_numpy_int16(self): self._test(numpy.array([-32768, 32767], numpy.int16)) def test_numpy_int32(self): self._test(numpy.array([-2147483647, 2147483647], numpy.int32)) def test_numpy_int64(self): self._test( numpy.array([-9223372036854775807, 9223372036854775807], numpy.int64) ) @pytest.mark.skip(reason="tolist() conversion results in 3.4028234663852886e38") def test_numpy_float32(self): self._test( numpy.array( [ -340282346638528859811704183484516925440.0000000000000000, 340282346638528859811704183484516925440.0000000000000000, ], numpy.float32, ) ) self._test(numpy.array([-3.4028235e38, 3.4028235e38], numpy.float32)) def test_numpy_float64(self): self._test( numpy.array( [-1.7976931348623157e308, 1.7976931348623157e308], numpy.float64 ) ) orjson-3.9.15/test/test_parsing.py000066400000000000000000001572301456615046100171760ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson from .util import read_fixture_bytes class TestJSONTestSuiteParsing: def _run_fail_json(self, filename, exc=orjson.JSONDecodeError): data = read_fixture_bytes(filename, "parsing") with pytest.raises(exc): orjson.loads(data) with pytest.raises(exc): orjson.loads(bytearray(data)) with pytest.raises(exc): orjson.loads(memoryview(data)) try: decoded = data.decode("utf-8") except UnicodeDecodeError: pass else: with pytest.raises(exc): orjson.loads(decoded) def _run_pass_json(self, filename, match=""): data = read_fixture_bytes(filename, "parsing") orjson.loads(data) orjson.loads(bytearray(data)) orjson.loads(memoryview(data)) orjson.loads(data.decode("utf-8")) def test_y_array_arraysWithSpace(self): """ y_array_arraysWithSpaces.json """ self._run_pass_json("y_array_arraysWithSpaces.json") def test_y_array_empty_string(self): """ y_array_empty-string.json """ self._run_pass_json("y_array_empty-string.json") def test_y_array_empty(self): """ y_array_empty.json """ self._run_pass_json("y_array_empty.json") def test_y_array_ending_with_newline(self): """ y_array_ending_with_newline.json """ self._run_pass_json("y_array_ending_with_newline.json") def test_y_array_false(self): """ y_array_false.json """ self._run_pass_json("y_array_false.json") def test_y_array_heterogeneou(self): """ y_array_heterogeneous.json """ self._run_pass_json("y_array_heterogeneous.json") def test_y_array_null(self): """ y_array_null.json """ self._run_pass_json("y_array_null.json") def test_y_array_with_1_and_newline(self): """ y_array_with_1_and_newline.json """ self._run_pass_json("y_array_with_1_and_newline.json") def test_y_array_with_leading_space(self): """ y_array_with_leading_space.json """ self._run_pass_json("y_array_with_leading_space.json") def test_y_array_with_several_null(self): """ y_array_with_several_null.json """ self._run_pass_json("y_array_with_several_null.json") def test_y_array_with_trailing_space(self): """ y_array_with_trailing_space.json """ self._run_pass_json("y_array_with_trailing_space.json") def test_y_number(self): """ y_number.json """ self._run_pass_json("y_number.json") def test_y_number_0e_1(self): """ y_number_0e+1.json """ self._run_pass_json("y_number_0e+1.json") def test_y_number_0e1(self): """ y_number_0e1.json """ self._run_pass_json("y_number_0e1.json") def test_y_number_after_space(self): """ y_number_after_space.json """ self._run_pass_json("y_number_after_space.json") def test_y_number_double_close_to_zer(self): """ y_number_double_close_to_zero.json """ self._run_pass_json("y_number_double_close_to_zero.json") def test_y_number_int_with_exp(self): """ y_number_int_with_exp.json """ self._run_pass_json("y_number_int_with_exp.json") def test_y_number_minus_zer(self): """ y_number_minus_zero.json """ self._run_pass_json("y_number_minus_zero.json") def test_y_number_negative_int(self): """ y_number_negative_int.json """ self._run_pass_json("y_number_negative_int.json") def test_y_number_negative_one(self): """ y_number_negative_one.json """ self._run_pass_json("y_number_negative_one.json") def test_y_number_negative_zer(self): """ y_number_negative_zero.json """ self._run_pass_json("y_number_negative_zero.json") def test_y_number_real_capital_e(self): """ y_number_real_capital_e.json """ self._run_pass_json("y_number_real_capital_e.json") def test_y_number_real_capital_e_neg_exp(self): """ y_number_real_capital_e_neg_exp.json """ self._run_pass_json("y_number_real_capital_e_neg_exp.json") def test_y_number_real_capital_e_pos_exp(self): """ y_number_real_capital_e_pos_exp.json """ self._run_pass_json("y_number_real_capital_e_pos_exp.json") def test_y_number_real_exponent(self): """ y_number_real_exponent.json """ self._run_pass_json("y_number_real_exponent.json") def test_y_number_real_fraction_exponent(self): """ y_number_real_fraction_exponent.json """ self._run_pass_json("y_number_real_fraction_exponent.json") def test_y_number_real_neg_exp(self): """ y_number_real_neg_exp.json """ self._run_pass_json("y_number_real_neg_exp.json") def test_y_number_real_pos_exponent(self): """ y_number_real_pos_exponent.json """ self._run_pass_json("y_number_real_pos_exponent.json") def test_y_number_simple_int(self): """ y_number_simple_int.json """ self._run_pass_json("y_number_simple_int.json") def test_y_number_simple_real(self): """ y_number_simple_real.json """ self._run_pass_json("y_number_simple_real.json") def test_y_object(self): """ y_object.json """ self._run_pass_json("y_object.json") def test_y_object_basic(self): """ y_object_basic.json """ self._run_pass_json("y_object_basic.json") def test_y_object_duplicated_key(self): """ y_object_duplicated_key.json """ self._run_pass_json("y_object_duplicated_key.json") def test_y_object_duplicated_key_and_value(self): """ y_object_duplicated_key_and_value.json """ self._run_pass_json("y_object_duplicated_key_and_value.json") def test_y_object_empty(self): """ y_object_empty.json """ self._run_pass_json("y_object_empty.json") def test_y_object_empty_key(self): """ y_object_empty_key.json """ self._run_pass_json("y_object_empty_key.json") def test_y_object_escaped_null_in_key(self): """ y_object_escaped_null_in_key.json """ self._run_pass_json("y_object_escaped_null_in_key.json") def test_y_object_extreme_number(self): """ y_object_extreme_numbers.json """ self._run_pass_json("y_object_extreme_numbers.json") def test_y_object_long_string(self): """ y_object_long_strings.json """ self._run_pass_json("y_object_long_strings.json") def test_y_object_simple(self): """ y_object_simple.json """ self._run_pass_json("y_object_simple.json") def test_y_object_string_unicode(self): """ y_object_string_unicode.json """ self._run_pass_json("y_object_string_unicode.json") def test_y_object_with_newline(self): """ y_object_with_newlines.json """ self._run_pass_json("y_object_with_newlines.json") def test_y_string_1_2_3_bytes_UTF_8_sequence(self): """ y_string_1_2_3_bytes_UTF-8_sequences.json """ self._run_pass_json("y_string_1_2_3_bytes_UTF-8_sequences.json") def test_y_string_accepted_surrogate_pair(self): """ y_string_accepted_surrogate_pair.json """ self._run_pass_json("y_string_accepted_surrogate_pair.json") def test_y_string_accepted_surrogate_pairs(self): """ y_string_accepted_surrogate_pairs.json """ self._run_pass_json("y_string_accepted_surrogate_pairs.json") def test_y_string_allowed_escape(self): """ y_string_allowed_escapes.json """ self._run_pass_json("y_string_allowed_escapes.json") def test_y_string_backslash_and_u_escaped_zer(self): """ y_string_backslash_and_u_escaped_zero.json """ self._run_pass_json("y_string_backslash_and_u_escaped_zero.json") def test_y_string_backslash_doublequote(self): """ y_string_backslash_doublequotes.json """ self._run_pass_json("y_string_backslash_doublequotes.json") def test_y_string_comment(self): """ y_string_comments.json """ self._run_pass_json("y_string_comments.json") def test_y_string_double_escape_a(self): """ y_string_double_escape_a.json """ self._run_pass_json("y_string_double_escape_a.json") def test_y_string_double_escape_(self): """ y_string_double_escape_n.json """ self._run_pass_json("y_string_double_escape_n.json") def test_y_string_escaped_control_character(self): """ y_string_escaped_control_character.json """ self._run_pass_json("y_string_escaped_control_character.json") def test_y_string_escaped_noncharacter(self): """ y_string_escaped_noncharacter.json """ self._run_pass_json("y_string_escaped_noncharacter.json") def test_y_string_in_array(self): """ y_string_in_array.json """ self._run_pass_json("y_string_in_array.json") def test_y_string_in_array_with_leading_space(self): """ y_string_in_array_with_leading_space.json """ self._run_pass_json("y_string_in_array_with_leading_space.json") def test_y_string_last_surrogates_1_and_2(self): """ y_string_last_surrogates_1_and_2.json """ self._run_pass_json("y_string_last_surrogates_1_and_2.json") def test_y_string_nbsp_uescaped(self): """ y_string_nbsp_uescaped.json """ self._run_pass_json("y_string_nbsp_uescaped.json") def test_y_string_nonCharacterInUTF_8_U_10FFFF(self): """ y_string_nonCharacterInUTF-8_U+10FFFF.json """ self._run_pass_json("y_string_nonCharacterInUTF-8_U+10FFFF.json") def test_y_string_nonCharacterInUTF_8_U_FFFF(self): """ y_string_nonCharacterInUTF-8_U+FFFF.json """ self._run_pass_json("y_string_nonCharacterInUTF-8_U+FFFF.json") def test_y_string_null_escape(self): """ y_string_null_escape.json """ self._run_pass_json("y_string_null_escape.json") def test_y_string_one_byte_utf_8(self): """ y_string_one-byte-utf-8.json """ self._run_pass_json("y_string_one-byte-utf-8.json") def test_y_string_pi(self): """ y_string_pi.json """ self._run_pass_json("y_string_pi.json") def test_y_string_reservedCharacterInUTF_8_U_1BFFF(self): """ y_string_reservedCharacterInUTF-8_U+1BFFF.json """ self._run_pass_json("y_string_reservedCharacterInUTF-8_U+1BFFF.json") def test_y_string_simple_ascii(self): """ y_string_simple_ascii.json """ self._run_pass_json("y_string_simple_ascii.json") def test_y_string_space(self): """ y_string_space.json """ self._run_pass_json("y_string_space.json") def test_y_string_surrogates_U_1D11E_MUSICAL_SYMBOL_G_CLEF(self): """ y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json """ self._run_pass_json("y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json") def test_y_string_three_byte_utf_8(self): """ y_string_three-byte-utf-8.json """ self._run_pass_json("y_string_three-byte-utf-8.json") def test_y_string_two_byte_utf_8(self): """ y_string_two-byte-utf-8.json """ self._run_pass_json("y_string_two-byte-utf-8.json") def test_y_string_u_2028_line_sep(self): """ y_string_u+2028_line_sep.json """ self._run_pass_json("y_string_u+2028_line_sep.json") def test_y_string_u_2029_par_sep(self): """ y_string_u+2029_par_sep.json """ self._run_pass_json("y_string_u+2029_par_sep.json") def test_y_string_uEscape(self): """ y_string_uEscape.json """ self._run_pass_json("y_string_uEscape.json") def test_y_string_uescaped_newline(self): """ y_string_uescaped_newline.json """ self._run_pass_json("y_string_uescaped_newline.json") def test_y_string_unescaped_char_delete(self): """ y_string_unescaped_char_delete.json """ self._run_pass_json("y_string_unescaped_char_delete.json") def test_y_string_unicode(self): """ y_string_unicode.json """ self._run_pass_json("y_string_unicode.json") def test_y_string_unicodeEscapedBackslash(self): """ y_string_unicodeEscapedBackslash.json """ self._run_pass_json("y_string_unicodeEscapedBackslash.json") def test_y_string_unicode_2(self): """ y_string_unicode_2.json """ self._run_pass_json("y_string_unicode_2.json") def test_y_string_unicode_U_10FFFE_nonchar(self): """ y_string_unicode_U+10FFFE_nonchar.json """ self._run_pass_json("y_string_unicode_U+10FFFE_nonchar.json") def test_y_string_unicode_U_1FFFE_nonchar(self): """ y_string_unicode_U+1FFFE_nonchar.json """ self._run_pass_json("y_string_unicode_U+1FFFE_nonchar.json") def test_y_string_unicode_U_200B_ZERO_WIDTH_SPACE(self): """ y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json """ self._run_pass_json("y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json") def test_y_string_unicode_U_2064_invisible_plu(self): """ y_string_unicode_U+2064_invisible_plus.json """ self._run_pass_json("y_string_unicode_U+2064_invisible_plus.json") def test_y_string_unicode_U_FDD0_nonchar(self): """ y_string_unicode_U+FDD0_nonchar.json """ self._run_pass_json("y_string_unicode_U+FDD0_nonchar.json") def test_y_string_unicode_U_FFFE_nonchar(self): """ y_string_unicode_U+FFFE_nonchar.json """ self._run_pass_json("y_string_unicode_U+FFFE_nonchar.json") def test_y_string_unicode_escaped_double_quote(self): """ y_string_unicode_escaped_double_quote.json """ self._run_pass_json("y_string_unicode_escaped_double_quote.json") def test_y_string_utf8(self): """ y_string_utf8.json """ self._run_pass_json("y_string_utf8.json") def test_y_string_with_del_character(self): """ y_string_with_del_character.json """ self._run_pass_json("y_string_with_del_character.json") def test_y_structure_lonely_false(self): """ y_structure_lonely_false.json """ self._run_pass_json("y_structure_lonely_false.json") def test_y_structure_lonely_int(self): """ y_structure_lonely_int.json """ self._run_pass_json("y_structure_lonely_int.json") def test_y_structure_lonely_negative_real(self): """ y_structure_lonely_negative_real.json """ self._run_pass_json("y_structure_lonely_negative_real.json") def test_y_structure_lonely_null(self): """ y_structure_lonely_null.json """ self._run_pass_json("y_structure_lonely_null.json") def test_y_structure_lonely_string(self): """ y_structure_lonely_string.json """ self._run_pass_json("y_structure_lonely_string.json") def test_y_structure_lonely_true(self): """ y_structure_lonely_true.json """ self._run_pass_json("y_structure_lonely_true.json") def test_y_structure_string_empty(self): """ y_structure_string_empty.json """ self._run_pass_json("y_structure_string_empty.json") def test_y_structure_trailing_newline(self): """ y_structure_trailing_newline.json """ self._run_pass_json("y_structure_trailing_newline.json") def test_y_structure_true_in_array(self): """ y_structure_true_in_array.json """ self._run_pass_json("y_structure_true_in_array.json") def test_y_structure_whitespace_array(self): """ y_structure_whitespace_array.json """ self._run_pass_json("y_structure_whitespace_array.json") def test_n_array_1_true_without_comma(self): """ n_array_1_true_without_comma.json """ self._run_fail_json("n_array_1_true_without_comma.json") def test_n_array_a_invalid_utf8(self): """ n_array_a_invalid_utf8.json """ self._run_fail_json("n_array_a_invalid_utf8.json") def test_n_array_colon_instead_of_comma(self): """ n_array_colon_instead_of_comma.json """ self._run_fail_json("n_array_colon_instead_of_comma.json") def test_n_array_comma_after_close(self): """ n_array_comma_after_close.json """ self._run_fail_json("n_array_comma_after_close.json") def test_n_array_comma_and_number(self): """ n_array_comma_and_number.json """ self._run_fail_json("n_array_comma_and_number.json") def test_n_array_double_comma(self): """ n_array_double_comma.json """ self._run_fail_json("n_array_double_comma.json") def test_n_array_double_extra_comma(self): """ n_array_double_extra_comma.json """ self._run_fail_json("n_array_double_extra_comma.json") def test_n_array_extra_close(self): """ n_array_extra_close.json """ self._run_fail_json("n_array_extra_close.json") def test_n_array_extra_comma(self): """ n_array_extra_comma.json """ self._run_fail_json("n_array_extra_comma.json") def test_n_array_incomplete(self): """ n_array_incomplete.json """ self._run_fail_json("n_array_incomplete.json") def test_n_array_incomplete_invalid_value(self): """ n_array_incomplete_invalid_value.json """ self._run_fail_json("n_array_incomplete_invalid_value.json") def test_n_array_inner_array_no_comma(self): """ n_array_inner_array_no_comma.json """ self._run_fail_json("n_array_inner_array_no_comma.json") def test_n_array_invalid_utf8(self): """ n_array_invalid_utf8.json """ self._run_fail_json("n_array_invalid_utf8.json") def test_n_array_items_separated_by_semicol(self): """ n_array_items_separated_by_semicolon.json """ self._run_fail_json("n_array_items_separated_by_semicolon.json") def test_n_array_just_comma(self): """ n_array_just_comma.json """ self._run_fail_json("n_array_just_comma.json") def test_n_array_just_minu(self): """ n_array_just_minus.json """ self._run_fail_json("n_array_just_minus.json") def test_n_array_missing_value(self): """ n_array_missing_value.json """ self._run_fail_json("n_array_missing_value.json") def test_n_array_newlines_unclosed(self): """ n_array_newlines_unclosed.json """ self._run_fail_json("n_array_newlines_unclosed.json") def test_n_array_number_and_comma(self): """ n_array_number_and_comma.json """ self._run_fail_json("n_array_number_and_comma.json") def test_n_array_number_and_several_comma(self): """ n_array_number_and_several_commas.json """ self._run_fail_json("n_array_number_and_several_commas.json") def test_n_array_spaces_vertical_tab_formfeed(self): """ n_array_spaces_vertical_tab_formfeed.json """ self._run_fail_json("n_array_spaces_vertical_tab_formfeed.json") def test_n_array_star_inside(self): """ n_array_star_inside.json """ self._run_fail_json("n_array_star_inside.json") def test_n_array_unclosed(self): """ n_array_unclosed.json """ self._run_fail_json("n_array_unclosed.json") def test_n_array_unclosed_trailing_comma(self): """ n_array_unclosed_trailing_comma.json """ self._run_fail_json("n_array_unclosed_trailing_comma.json") def test_n_array_unclosed_with_new_line(self): """ n_array_unclosed_with_new_lines.json """ self._run_fail_json("n_array_unclosed_with_new_lines.json") def test_n_array_unclosed_with_object_inside(self): """ n_array_unclosed_with_object_inside.json """ self._run_fail_json("n_array_unclosed_with_object_inside.json") def test_n_incomplete_false(self): """ n_incomplete_false.json """ self._run_fail_json("n_incomplete_false.json") def test_n_incomplete_null(self): """ n_incomplete_null.json """ self._run_fail_json("n_incomplete_null.json") def test_n_incomplete_true(self): """ n_incomplete_true.json """ self._run_fail_json("n_incomplete_true.json") def test_n_multidigit_number_then_00(self): """ n_multidigit_number_then_00.json """ self._run_fail_json("n_multidigit_number_then_00.json") def test_n_number__(self): """ n_number_++.json """ self._run_fail_json("n_number_++.json") def test_n_number_1(self): """ n_number_+1.json """ self._run_fail_json("n_number_+1.json") def test_n_number_Inf(self): """ n_number_+Inf.json """ self._run_fail_json("n_number_+Inf.json") def test_n_number_01(self): """ n_number_-01.json """ self._run_fail_json("n_number_-01.json") def test_n_number_1_0(self): """ n_number_-1.0..json """ self._run_fail_json("n_number_-1.0..json") def test_n_number_2(self): """ n_number_-2..json """ self._run_fail_json("n_number_-2..json") def test_n_number_negative_NaN(self): """ n_number_-NaN.json """ self._run_fail_json("n_number_-NaN.json") def test_n_number_negative_1(self): """ n_number_.-1.json """ self._run_fail_json("n_number_.-1.json") def test_n_number_2e_3(self): """ n_number_.2e-3.json """ self._run_fail_json("n_number_.2e-3.json") def test_n_number_0_1_2(self): """ n_number_0.1.2.json """ self._run_fail_json("n_number_0.1.2.json") def test_n_number_0_3e_(self): """ n_number_0.3e+.json """ self._run_fail_json("n_number_0.3e+.json") def test_n_number_0_3e(self): """ n_number_0.3e.json """ self._run_fail_json("n_number_0.3e.json") def test_n_number_0_e1(self): """ n_number_0.e1.json """ self._run_fail_json("n_number_0.e1.json") def test_n_number_0_capital_E_(self): """ n_number_0_capital_E+.json """ self._run_fail_json("n_number_0_capital_E+.json") def test_n_number_0_capital_E(self): """ n_number_0_capital_E.json """ self._run_fail_json("n_number_0_capital_E.json") def test_n_number_0e_(self): """ n_number_0e+.json """ self._run_fail_json("n_number_0e+.json") def test_n_number_0e(self): """ n_number_0e.json """ self._run_fail_json("n_number_0e.json") def test_n_number_1_0e_(self): """ n_number_1.0e+.json """ self._run_fail_json("n_number_1.0e+.json") def test_n_number_1_0e_2(self): """ n_number_1.0e-.json """ self._run_fail_json("n_number_1.0e-.json") def test_n_number_1_0e(self): """ n_number_1.0e.json """ self._run_fail_json("n_number_1.0e.json") def test_n_number_1_000(self): """ n_number_1_000.json """ self._run_fail_json("n_number_1_000.json") def test_n_number_1eE2(self): """ n_number_1eE2.json """ self._run_fail_json("n_number_1eE2.json") def test_n_number_2_e_3(self): """ n_number_2.e+3.json """ self._run_fail_json("n_number_2.e+3.json") def test_n_number_2_e_3_2(self): """ n_number_2.e-3.json """ self._run_fail_json("n_number_2.e-3.json") def test_n_number_2_e3_3(self): """ n_number_2.e3.json """ self._run_fail_json("n_number_2.e3.json") def test_n_number_9_e_(self): """ n_number_9.e+.json """ self._run_fail_json("n_number_9.e+.json") def test_n_number_negative_Inf(self): """ n_number_Inf.json """ self._run_fail_json("n_number_Inf.json") def test_n_number_NaN(self): """ n_number_NaN.json """ self._run_fail_json("n_number_NaN.json") def test_n_number_U_FF11_fullwidth_digit_one(self): """ n_number_U+FF11_fullwidth_digit_one.json """ self._run_fail_json("n_number_U+FF11_fullwidth_digit_one.json") def test_n_number_expressi(self): """ n_number_expression.json """ self._run_fail_json("n_number_expression.json") def test_n_number_hex_1_digit(self): """ n_number_hex_1_digit.json """ self._run_fail_json("n_number_hex_1_digit.json") def test_n_number_hex_2_digit(self): """ n_number_hex_2_digits.json """ self._run_fail_json("n_number_hex_2_digits.json") def test_n_number_infinity(self): """ n_number_infinity.json """ self._run_fail_json("n_number_infinity.json") def test_n_number_invalid_(self): """ n_number_invalid+-.json """ self._run_fail_json("n_number_invalid+-.json") def test_n_number_invalid_negative_real(self): """ n_number_invalid-negative-real.json """ self._run_fail_json("n_number_invalid-negative-real.json") def test_n_number_invalid_utf_8_in_bigger_int(self): """ n_number_invalid-utf-8-in-bigger-int.json """ self._run_fail_json("n_number_invalid-utf-8-in-bigger-int.json") def test_n_number_invalid_utf_8_in_exponent(self): """ n_number_invalid-utf-8-in-exponent.json """ self._run_fail_json("n_number_invalid-utf-8-in-exponent.json") def test_n_number_invalid_utf_8_in_int(self): """ n_number_invalid-utf-8-in-int.json """ self._run_fail_json("n_number_invalid-utf-8-in-int.json") def test_n_number_minus_infinity(self): """ n_number_minus_infinity.json """ self._run_fail_json("n_number_minus_infinity.json") def test_n_number_minus_sign_with_trailing_garbage(self): """ n_number_minus_sign_with_trailing_garbage.json """ self._run_fail_json("n_number_minus_sign_with_trailing_garbage.json") def test_n_number_minus_space_1(self): """ n_number_minus_space_1.json """ self._run_fail_json("n_number_minus_space_1.json") def test_n_number_neg_int_starting_with_zer(self): """ n_number_neg_int_starting_with_zero.json """ self._run_fail_json("n_number_neg_int_starting_with_zero.json") def test_n_number_neg_real_without_int_part(self): """ n_number_neg_real_without_int_part.json """ self._run_fail_json("n_number_neg_real_without_int_part.json") def test_n_number_neg_with_garbage_at_end(self): """ n_number_neg_with_garbage_at_end.json """ self._run_fail_json("n_number_neg_with_garbage_at_end.json") def test_n_number_real_garbage_after_e(self): """ n_number_real_garbage_after_e.json """ self._run_fail_json("n_number_real_garbage_after_e.json") def test_n_number_real_with_invalid_utf8_after_e(self): """ n_number_real_with_invalid_utf8_after_e.json """ self._run_fail_json("n_number_real_with_invalid_utf8_after_e.json") def test_n_number_real_without_fractional_part(self): """ n_number_real_without_fractional_part.json """ self._run_fail_json("n_number_real_without_fractional_part.json") def test_n_number_starting_with_dot(self): """ n_number_starting_with_dot.json """ self._run_fail_json("n_number_starting_with_dot.json") def test_n_number_with_alpha(self): """ n_number_with_alpha.json """ self._run_fail_json("n_number_with_alpha.json") def test_n_number_with_alpha_char(self): """ n_number_with_alpha_char.json """ self._run_fail_json("n_number_with_alpha_char.json") def test_n_number_with_leading_zer(self): """ n_number_with_leading_zero.json """ self._run_fail_json("n_number_with_leading_zero.json") def test_n_object_bad_value(self): """ n_object_bad_value.json """ self._run_fail_json("n_object_bad_value.json") def test_n_object_bracket_key(self): """ n_object_bracket_key.json """ self._run_fail_json("n_object_bracket_key.json") def test_n_object_comma_instead_of_col(self): """ n_object_comma_instead_of_colon.json """ self._run_fail_json("n_object_comma_instead_of_colon.json") def test_n_object_double_col(self): """ n_object_double_colon.json """ self._run_fail_json("n_object_double_colon.json") def test_n_object_emoji(self): """ n_object_emoji.json """ self._run_fail_json("n_object_emoji.json") def test_n_object_garbage_at_end(self): """ n_object_garbage_at_end.json """ self._run_fail_json("n_object_garbage_at_end.json") def test_n_object_key_with_single_quote(self): """ n_object_key_with_single_quotes.json """ self._run_fail_json("n_object_key_with_single_quotes.json") def test_n_object_lone_continuation_byte_in_key_and_trailing_comma(self): """ n_object_lone_continuation_byte_in_key_and_trailing_comma.json """ self._run_fail_json( "n_object_lone_continuation_byte_in_key_and_trailing_comma.json" ) def test_n_object_missing_col(self): """ n_object_missing_colon.json """ self._run_fail_json("n_object_missing_colon.json") def test_n_object_missing_key(self): """ n_object_missing_key.json """ self._run_fail_json("n_object_missing_key.json") def test_n_object_missing_semicol(self): """ n_object_missing_semicolon.json """ self._run_fail_json("n_object_missing_semicolon.json") def test_n_object_missing_value(self): """ n_object_missing_value.json """ self._run_fail_json("n_object_missing_value.json") def test_n_object_no_col(self): """ n_object_no-colon.json """ self._run_fail_json("n_object_no-colon.json") def test_n_object_non_string_key(self): """ n_object_non_string_key.json """ self._run_fail_json("n_object_non_string_key.json") def test_n_object_non_string_key_but_huge_number_instead(self): """ n_object_non_string_key_but_huge_number_instead.json """ self._run_fail_json("n_object_non_string_key_but_huge_number_instead.json") def test_n_object_repeated_null_null(self): """ n_object_repeated_null_null.json """ self._run_fail_json("n_object_repeated_null_null.json") def test_n_object_several_trailing_comma(self): """ n_object_several_trailing_commas.json """ self._run_fail_json("n_object_several_trailing_commas.json") def test_n_object_single_quote(self): """ n_object_single_quote.json """ self._run_fail_json("n_object_single_quote.json") def test_n_object_trailing_comma(self): """ n_object_trailing_comma.json """ self._run_fail_json("n_object_trailing_comma.json") def test_n_object_trailing_comment(self): """ n_object_trailing_comment.json """ self._run_fail_json("n_object_trailing_comment.json") def test_n_object_trailing_comment_ope(self): """ n_object_trailing_comment_open.json """ self._run_fail_json("n_object_trailing_comment_open.json") def test_n_object_trailing_comment_slash_ope(self): """ n_object_trailing_comment_slash_open.json """ self._run_fail_json("n_object_trailing_comment_slash_open.json") def test_n_object_trailing_comment_slash_open_incomplete(self): """ n_object_trailing_comment_slash_open_incomplete.json """ self._run_fail_json("n_object_trailing_comment_slash_open_incomplete.json") def test_n_object_two_commas_in_a_row(self): """ n_object_two_commas_in_a_row.json """ self._run_fail_json("n_object_two_commas_in_a_row.json") def test_n_object_unquoted_key(self): """ n_object_unquoted_key.json """ self._run_fail_json("n_object_unquoted_key.json") def test_n_object_unterminated_value(self): """ n_object_unterminated-value.json """ self._run_fail_json("n_object_unterminated-value.json") def test_n_object_with_single_string(self): """ n_object_with_single_string.json """ self._run_fail_json("n_object_with_single_string.json") def test_n_object_with_trailing_garbage(self): """ n_object_with_trailing_garbage.json """ self._run_fail_json("n_object_with_trailing_garbage.json") def test_n_single_space(self): """ n_single_space.json """ self._run_fail_json("n_single_space.json") def test_n_string_1_surrogate_then_escape(self): """ n_string_1_surrogate_then_escape.json """ self._run_fail_json("n_string_1_surrogate_then_escape.json") def test_n_string_1_surrogate_then_escape_u(self): """ n_string_1_surrogate_then_escape_u.json """ self._run_fail_json("n_string_1_surrogate_then_escape_u.json") def test_n_string_1_surrogate_then_escape_u1(self): """ n_string_1_surrogate_then_escape_u1.json """ self._run_fail_json("n_string_1_surrogate_then_escape_u1.json") def test_n_string_1_surrogate_then_escape_u1x(self): """ n_string_1_surrogate_then_escape_u1x.json """ self._run_fail_json("n_string_1_surrogate_then_escape_u1x.json") def test_n_string_accentuated_char_no_quote(self): """ n_string_accentuated_char_no_quotes.json """ self._run_fail_json("n_string_accentuated_char_no_quotes.json") def test_n_string_backslash_00(self): """ n_string_backslash_00.json """ self._run_fail_json("n_string_backslash_00.json") def test_n_string_escape_x(self): """ n_string_escape_x.json """ self._run_fail_json("n_string_escape_x.json") def test_n_string_escaped_backslash_bad(self): """ n_string_escaped_backslash_bad.json """ self._run_fail_json("n_string_escaped_backslash_bad.json") def test_n_string_escaped_ctrl_char_tab(self): """ n_string_escaped_ctrl_char_tab.json """ self._run_fail_json("n_string_escaped_ctrl_char_tab.json") def test_n_string_escaped_emoji(self): """ n_string_escaped_emoji.json """ self._run_fail_json("n_string_escaped_emoji.json") def test_n_string_incomplete_escape(self): """ n_string_incomplete_escape.json """ self._run_fail_json("n_string_incomplete_escape.json") def test_n_string_incomplete_escaped_character(self): """ n_string_incomplete_escaped_character.json """ self._run_fail_json("n_string_incomplete_escaped_character.json") def test_n_string_incomplete_surrogate(self): """ n_string_incomplete_surrogate.json """ self._run_fail_json("n_string_incomplete_surrogate.json") def test_n_string_incomplete_surrogate_escape_invalid(self): """ n_string_incomplete_surrogate_escape_invalid.json """ self._run_fail_json("n_string_incomplete_surrogate_escape_invalid.json") def test_n_string_invalid_utf_8_in_escape(self): """ n_string_invalid-utf-8-in-escape.json """ self._run_fail_json("n_string_invalid-utf-8-in-escape.json") def test_n_string_invalid_backslash_esc(self): """ n_string_invalid_backslash_esc.json """ self._run_fail_json("n_string_invalid_backslash_esc.json") def test_n_string_invalid_unicode_escape(self): """ n_string_invalid_unicode_escape.json """ self._run_fail_json("n_string_invalid_unicode_escape.json") def test_n_string_invalid_utf8_after_escape(self): """ n_string_invalid_utf8_after_escape.json """ self._run_fail_json("n_string_invalid_utf8_after_escape.json") def test_n_string_leading_uescaped_thinspace(self): """ n_string_leading_uescaped_thinspace.json """ self._run_fail_json("n_string_leading_uescaped_thinspace.json") def test_n_string_no_quotes_with_bad_escape(self): """ n_string_no_quotes_with_bad_escape.json """ self._run_fail_json("n_string_no_quotes_with_bad_escape.json") def test_n_string_single_doublequote(self): """ n_string_single_doublequote.json """ self._run_fail_json("n_string_single_doublequote.json") def test_n_string_single_quote(self): """ n_string_single_quote.json """ self._run_fail_json("n_string_single_quote.json") def test_n_string_single_string_no_double_quote(self): """ n_string_single_string_no_double_quotes.json """ self._run_fail_json("n_string_single_string_no_double_quotes.json") def test_n_string_start_escape_unclosed(self): """ n_string_start_escape_unclosed.json """ self._run_fail_json("n_string_start_escape_unclosed.json") def test_n_string_unescaped_crtl_char(self): """ n_string_unescaped_crtl_char.json """ self._run_fail_json("n_string_unescaped_crtl_char.json") def test_n_string_unescaped_newline(self): """ n_string_unescaped_newline.json """ self._run_fail_json("n_string_unescaped_newline.json") def test_n_string_unescaped_tab(self): """ n_string_unescaped_tab.json """ self._run_fail_json("n_string_unescaped_tab.json") def test_n_string_unicode_CapitalU(self): """ n_string_unicode_CapitalU.json """ self._run_fail_json("n_string_unicode_CapitalU.json") def test_n_string_with_trailing_garbage(self): """ n_string_with_trailing_garbage.json """ self._run_fail_json("n_string_with_trailing_garbage.json") def test_n_structure_100000_opening_array(self): """ n_structure_100000_opening_arrays.json """ self._run_fail_json("n_structure_100000_opening_arrays.json.xz") def test_n_structure_U_2060_word_joined(self): """ n_structure_U+2060_word_joined.json """ self._run_fail_json("n_structure_U+2060_word_joined.json") def test_n_structure_UTF8_BOM_no_data(self): """ n_structure_UTF8_BOM_no_data.json """ self._run_fail_json("n_structure_UTF8_BOM_no_data.json") def test_n_structure_angle_bracket_(self): """ n_structure_angle_bracket_..json """ self._run_fail_json("n_structure_angle_bracket_..json") def test_n_structure_angle_bracket_null(self): """ n_structure_angle_bracket_null.json """ self._run_fail_json("n_structure_angle_bracket_null.json") def test_n_structure_array_trailing_garbage(self): """ n_structure_array_trailing_garbage.json """ self._run_fail_json("n_structure_array_trailing_garbage.json") def test_n_structure_array_with_extra_array_close(self): """ n_structure_array_with_extra_array_close.json """ self._run_fail_json("n_structure_array_with_extra_array_close.json") def test_n_structure_array_with_unclosed_string(self): """ n_structure_array_with_unclosed_string.json """ self._run_fail_json("n_structure_array_with_unclosed_string.json") def test_n_structure_ascii_unicode_identifier(self): """ n_structure_ascii-unicode-identifier.json """ self._run_fail_json("n_structure_ascii-unicode-identifier.json") def test_n_structure_capitalized_True(self): """ n_structure_capitalized_True.json """ self._run_fail_json("n_structure_capitalized_True.json") def test_n_structure_close_unopened_array(self): """ n_structure_close_unopened_array.json """ self._run_fail_json("n_structure_close_unopened_array.json") def test_n_structure_comma_instead_of_closing_brace(self): """ n_structure_comma_instead_of_closing_brace.json """ self._run_fail_json("n_structure_comma_instead_of_closing_brace.json") def test_n_structure_double_array(self): """ n_structure_double_array.json """ self._run_fail_json("n_structure_double_array.json") def test_n_structure_end_array(self): """ n_structure_end_array.json """ self._run_fail_json("n_structure_end_array.json") def test_n_structure_incomplete_UTF8_BOM(self): """ n_structure_incomplete_UTF8_BOM.json """ self._run_fail_json("n_structure_incomplete_UTF8_BOM.json") def test_n_structure_lone_invalid_utf_8(self): """ n_structure_lone-invalid-utf-8.json """ self._run_fail_json("n_structure_lone-invalid-utf-8.json") def test_n_structure_lone_open_bracket(self): """ n_structure_lone-open-bracket.json """ self._run_fail_json("n_structure_lone-open-bracket.json") def test_n_structure_no_data(self): """ n_structure_no_data.json """ self._run_fail_json("n_structure_no_data.json") def test_n_structure_null_byte_outside_string(self): """ n_structure_null-byte-outside-string.json """ self._run_fail_json("n_structure_null-byte-outside-string.json") def test_n_structure_number_with_trailing_garbage(self): """ n_structure_number_with_trailing_garbage.json """ self._run_fail_json("n_structure_number_with_trailing_garbage.json") def test_n_structure_object_followed_by_closing_object(self): """ n_structure_object_followed_by_closing_object.json """ self._run_fail_json("n_structure_object_followed_by_closing_object.json") def test_n_structure_object_unclosed_no_value(self): """ n_structure_object_unclosed_no_value.json """ self._run_fail_json("n_structure_object_unclosed_no_value.json") def test_n_structure_object_with_comment(self): """ n_structure_object_with_comment.json """ self._run_fail_json("n_structure_object_with_comment.json") def test_n_structure_object_with_trailing_garbage(self): """ n_structure_object_with_trailing_garbage.json """ self._run_fail_json("n_structure_object_with_trailing_garbage.json") def test_n_structure_open_array_apostrophe(self): """ n_structure_open_array_apostrophe.json """ self._run_fail_json("n_structure_open_array_apostrophe.json") def test_n_structure_open_array_comma(self): """ n_structure_open_array_comma.json """ self._run_fail_json("n_structure_open_array_comma.json") def test_n_structure_open_array_object(self): """ n_structure_open_array_object.json """ self._run_fail_json("n_structure_open_array_object.json.xz") def test_n_structure_open_array_open_object(self): """ n_structure_open_array_open_object.json """ self._run_fail_json("n_structure_open_array_open_object.json") def test_n_structure_open_array_open_string(self): """ n_structure_open_array_open_string.json """ self._run_fail_json("n_structure_open_array_open_string.json") def test_n_structure_open_array_string(self): """ n_structure_open_array_string.json """ self._run_fail_json("n_structure_open_array_string.json") def test_n_structure_open_object(self): """ n_structure_open_object.json """ self._run_fail_json("n_structure_open_object.json") def test_n_structure_open_object_close_array(self): """ n_structure_open_object_close_array.json """ self._run_fail_json("n_structure_open_object_close_array.json") def test_n_structure_open_object_comma(self): """ n_structure_open_object_comma.json """ self._run_fail_json("n_structure_open_object_comma.json") def test_n_structure_open_object_open_array(self): """ n_structure_open_object_open_array.json """ self._run_fail_json("n_structure_open_object_open_array.json") def test_n_structure_open_object_open_string(self): """ n_structure_open_object_open_string.json """ self._run_fail_json("n_structure_open_object_open_string.json") def test_n_structure_open_object_string_with_apostrophe(self): """ n_structure_open_object_string_with_apostrophes.json """ self._run_fail_json("n_structure_open_object_string_with_apostrophes.json") def test_n_structure_open_ope(self): """ n_structure_open_open.json """ self._run_fail_json("n_structure_open_open.json") def test_n_structure_single_eacute(self): """ n_structure_single_eacute.json """ self._run_fail_json("n_structure_single_eacute.json") def test_n_structure_single_star(self): """ n_structure_single_star.json """ self._run_fail_json("n_structure_single_star.json") def test_n_structure_trailing_(self): """ n_structure_trailing_#.json """ self._run_fail_json("n_structure_trailing_#.json") def test_n_structure_uescaped_LF_before_string(self): """ n_structure_uescaped_LF_before_string.json """ self._run_fail_json("n_structure_uescaped_LF_before_string.json") def test_n_structure_unclosed_array(self): """ n_structure_unclosed_array.json """ self._run_fail_json("n_structure_unclosed_array.json") def test_n_structure_unclosed_array_partial_null(self): """ n_structure_unclosed_array_partial_null.json """ self._run_fail_json("n_structure_unclosed_array_partial_null.json") def test_n_structure_unclosed_array_unfinished_false(self): """ n_structure_unclosed_array_unfinished_false.json """ self._run_fail_json("n_structure_unclosed_array_unfinished_false.json") def test_n_structure_unclosed_array_unfinished_true(self): """ n_structure_unclosed_array_unfinished_true.json """ self._run_fail_json("n_structure_unclosed_array_unfinished_true.json") def test_n_structure_unclosed_object(self): """ n_structure_unclosed_object.json """ self._run_fail_json("n_structure_unclosed_object.json") def test_n_structure_unicode_identifier(self): """ n_structure_unicode-identifier.json """ self._run_fail_json("n_structure_unicode-identifier.json") def test_n_structure_whitespace_U_2060_word_joiner(self): """ n_structure_whitespace_U+2060_word_joiner.json """ self._run_fail_json("n_structure_whitespace_U+2060_word_joiner.json") def test_n_structure_whitespace_formfeed(self): """ n_structure_whitespace_formfeed.json """ self._run_fail_json("n_structure_whitespace_formfeed.json") def test_i_number_double_huge_neg_exp(self): """ i_number_double_huge_neg_exp.json """ self._run_pass_json("i_number_double_huge_neg_exp.json") def test_i_number_huge_exp(self): """ i_number_huge_exp.json """ self._run_fail_json("i_number_huge_exp.json") def test_i_number_neg_int_huge_exp(self): """ i_number_neg_int_huge_exp.json """ self._run_fail_json("i_number_neg_int_huge_exp.json") def test_i_number_pos_double_huge_exp(self): """ i_number_pos_double_huge_exp.json """ self._run_fail_json("i_number_pos_double_huge_exp.json") def test_i_number_real_neg_overflow(self): """ i_number_real_neg_overflow.json """ self._run_fail_json("i_number_real_neg_overflow.json") def test_i_number_real_pos_overflow(self): """ i_number_real_pos_overflow.json """ self._run_fail_json("i_number_real_pos_overflow.json") def test_i_number_real_underflow(self): """ i_number_real_underflow.json """ self._run_pass_json("i_number_real_underflow.json") def test_i_number_too_big_neg_int(self): """ i_number_too_big_neg_int.json """ self._run_pass_json("i_number_too_big_neg_int.json") def test_i_number_too_big_pos_int(self): """ i_number_too_big_pos_int.json """ self._run_pass_json("i_number_too_big_pos_int.json") def test_i_number_very_big_negative_int(self): """ i_number_very_big_negative_int.json """ self._run_pass_json("i_number_very_big_negative_int.json") def test_i_object_key_lone_2nd_surrogate(self): """ i_object_key_lone_2nd_surrogate.json """ self._run_fail_json("i_object_key_lone_2nd_surrogate.json") def test_i_string_1st_surrogate_but_2nd_missing(self): """ i_string_1st_surrogate_but_2nd_missing.json """ self._run_fail_json("i_string_1st_surrogate_but_2nd_missing.json") def test_i_string_1st_valid_surrogate_2nd_invalid(self): """ i_string_1st_valid_surrogate_2nd_invalid.json """ self._run_fail_json("i_string_1st_valid_surrogate_2nd_invalid.json") def test_i_string_UTF_16LE_with_BOM(self): """ i_string_UTF-16LE_with_BOM.json """ self._run_fail_json("i_string_UTF-16LE_with_BOM.json") def test_i_string_UTF_8_invalid_sequence(self): """ i_string_UTF-8_invalid_sequence.json """ self._run_fail_json("i_string_UTF-8_invalid_sequence.json") def test_i_string_UTF8_surrogate_U_D800(self): """ i_string_UTF8_surrogate_U+D800.json """ self._run_fail_json("i_string_UTF8_surrogate_U+D800.json") def test_i_string_incomplete_surrogate_and_escape_valid(self): """ i_string_incomplete_surrogate_and_escape_valid.json """ self._run_fail_json("i_string_incomplete_surrogate_and_escape_valid.json") def test_i_string_incomplete_surrogate_pair(self): """ i_string_incomplete_surrogate_pair.json """ self._run_fail_json("i_string_incomplete_surrogate_pair.json") def test_i_string_incomplete_surrogates_escape_valid(self): """ i_string_incomplete_surrogates_escape_valid.json """ self._run_fail_json("i_string_incomplete_surrogates_escape_valid.json") def test_i_string_invalid_lonely_surrogate(self): """ i_string_invalid_lonely_surrogate.json """ self._run_fail_json("i_string_invalid_lonely_surrogate.json") def test_i_string_invalid_surrogate(self): """ i_string_invalid_surrogate.json """ self._run_fail_json("i_string_invalid_surrogate.json") def test_i_string_invalid_utf_8(self): """ i_string_invalid_utf-8.json """ self._run_fail_json("i_string_invalid_utf-8.json") def test_i_string_inverted_surrogates_U_1D11E(self): """ i_string_inverted_surrogates_U+1D11E.json """ self._run_fail_json("i_string_inverted_surrogates_U+1D11E.json") def test_i_string_iso_latin_1(self): """ i_string_iso_latin_1.json """ self._run_fail_json("i_string_iso_latin_1.json") def test_i_string_lone_second_surrogate(self): """ i_string_lone_second_surrogate.json """ self._run_fail_json("i_string_lone_second_surrogate.json") def test_i_string_lone_utf8_continuation_byte(self): """ i_string_lone_utf8_continuation_byte.json """ self._run_fail_json("i_string_lone_utf8_continuation_byte.json") def test_i_string_not_in_unicode_range(self): """ i_string_not_in_unicode_range.json """ self._run_fail_json("i_string_not_in_unicode_range.json") def test_i_string_overlong_sequence_2_byte(self): """ i_string_overlong_sequence_2_bytes.json """ self._run_fail_json("i_string_overlong_sequence_2_bytes.json") def test_i_string_overlong_sequence_6_byte(self): """ i_string_overlong_sequence_6_bytes.json """ self._run_fail_json("i_string_overlong_sequence_6_bytes.json") def test_i_string_overlong_sequence_6_bytes_null(self): """ i_string_overlong_sequence_6_bytes_null.json """ self._run_fail_json("i_string_overlong_sequence_6_bytes_null.json") def test_i_string_truncated_utf_8(self): """ i_string_truncated-utf-8.json """ self._run_fail_json("i_string_truncated-utf-8.json") def test_i_string_utf16BE_no_BOM(self): """ i_string_utf16BE_no_BOM.json """ self._run_fail_json("i_string_utf16BE_no_BOM.json") def test_i_string_utf16LE_no_BOM(self): """ i_string_utf16LE_no_BOM.json """ self._run_fail_json("i_string_utf16LE_no_BOM.json") def test_i_structure_500_nested_array(self): """ i_structure_500_nested_arrays.json """ try: self._run_pass_json("i_structure_500_nested_arrays.json.xz") except orjson.JSONDecodeError: # fails on serde, passes on yyjson pass def test_i_structure_UTF_8_BOM_empty_object(self): """ i_structure_UTF-8_BOM_empty_object.json """ self._run_fail_json("i_structure_UTF-8_BOM_empty_object.json") orjson-3.9.15/test/test_reentrant.py000066400000000000000000000003221456615046100175220ustar00rootroot00000000000000import orjson class C: c: "C" def __del__(self): orjson.loads('"' + "a" * 10000 + '"') def test_reentrant(): c = C() c.c = c del c orjson.loads("[" + "[]," * 1000 + "[]]") orjson-3.9.15/test/test_roundtrip.py000066400000000000000000000076321456615046100175610ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson from .util import read_fixture_str class TestJsonChecker: def _run_roundtrip_json(self, filename): data = read_fixture_str(filename, "roundtrip") assert orjson.dumps(orjson.loads(data)) == data.encode("utf-8") def test_roundtrip001(self): """ roundtrip001.json """ self._run_roundtrip_json("roundtrip01.json") def test_roundtrip002(self): """ roundtrip002.json """ self._run_roundtrip_json("roundtrip02.json") def test_roundtrip003(self): """ roundtrip003.json """ self._run_roundtrip_json("roundtrip03.json") def test_roundtrip004(self): """ roundtrip004.json """ self._run_roundtrip_json("roundtrip04.json") def test_roundtrip005(self): """ roundtrip005.json """ self._run_roundtrip_json("roundtrip05.json") def test_roundtrip006(self): """ roundtrip006.json """ self._run_roundtrip_json("roundtrip06.json") def test_roundtrip007(self): """ roundtrip007.json """ self._run_roundtrip_json("roundtrip07.json") def test_roundtrip008(self): """ roundtrip008.json """ self._run_roundtrip_json("roundtrip08.json") def test_roundtrip009(self): """ roundtrip009.json """ self._run_roundtrip_json("roundtrip09.json") def test_roundtrip010(self): """ roundtrip010.json """ self._run_roundtrip_json("roundtrip10.json") def test_roundtrip011(self): """ roundtrip011.json """ self._run_roundtrip_json("roundtrip11.json") def test_roundtrip012(self): """ roundtrip012.json """ self._run_roundtrip_json("roundtrip12.json") def test_roundtrip013(self): """ roundtrip013.json """ self._run_roundtrip_json("roundtrip13.json") def test_roundtrip014(self): """ roundtrip014.json """ self._run_roundtrip_json("roundtrip14.json") def test_roundtrip015(self): """ roundtrip015.json """ self._run_roundtrip_json("roundtrip15.json") def test_roundtrip016(self): """ roundtrip016.json """ self._run_roundtrip_json("roundtrip16.json") def test_roundtrip017(self): """ roundtrip017.json """ self._run_roundtrip_json("roundtrip17.json") def test_roundtrip018(self): """ roundtrip018.json """ self._run_roundtrip_json("roundtrip18.json") def test_roundtrip019(self): """ roundtrip019.json """ self._run_roundtrip_json("roundtrip19.json") def test_roundtrip020(self): """ roundtrip020.json """ self._run_roundtrip_json("roundtrip20.json") def test_roundtrip021(self): """ roundtrip021.json """ self._run_roundtrip_json("roundtrip21.json") def test_roundtrip022(self): """ roundtrip022.json """ self._run_roundtrip_json("roundtrip22.json") def test_roundtrip023(self): """ roundtrip023.json """ self._run_roundtrip_json("roundtrip23.json") def test_roundtrip024(self): """ roundtrip024.json """ self._run_roundtrip_json("roundtrip24.json") def test_roundtrip025(self): """ roundtrip025.json """ self._run_roundtrip_json("roundtrip25.json") def test_roundtrip026(self): """ roundtrip026.json """ self._run_roundtrip_json("roundtrip26.json") def test_roundtrip027(self): """ roundtrip027.json """ self._run_roundtrip_json("roundtrip27.json") orjson-3.9.15/test/test_sort_keys.py000066400000000000000000000031701456615046100175460ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson from .util import read_fixture_obj class TestDictSortKeys: # citm_catalog is already sorted def test_twitter_sorted(self): """ twitter.json sorted """ obj = read_fixture_obj("twitter.json.xz") assert list(obj.keys()) != sorted(list(obj.keys())) serialized = orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) val = orjson.loads(serialized) assert list(val.keys()) == sorted(list(val.keys())) def test_canada_sorted(self): """ canada.json sorted """ obj = read_fixture_obj("canada.json.xz") assert list(obj.keys()) != sorted(list(obj.keys())) serialized = orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) val = orjson.loads(serialized) assert list(val.keys()) == sorted(list(val.keys())) def test_github_sorted(self): """ github.json sorted """ obj = read_fixture_obj("github.json.xz") for each in obj: assert list(each.keys()) != sorted(list(each.keys())) serialized = orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) val = orjson.loads(serialized) for each in val: assert list(each.keys()) == sorted(list(each.keys())) def test_utf8_sorted(self): """ UTF-8 sorted """ obj = {"a": 1, "ä": 2, "A": 3} assert list(obj.keys()) != sorted(list(obj.keys())) serialized = orjson.dumps(obj, option=orjson.OPT_SORT_KEYS) val = orjson.loads(serialized) assert list(val.keys()) == sorted(list(val.keys())) orjson-3.9.15/test/test_subclass.py000066400000000000000000000060661456615046100173520ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections import json import pytest import orjson class SubStr(str): pass class SubInt(int): pass class SubDict(dict): pass class SubList(list): pass class SubFloat(float): pass class SubTuple(tuple): pass class TestSubclass: def test_subclass_str(self): assert orjson.dumps(SubStr("zxc")) == b'"zxc"' def test_subclass_str_invalid(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubStr("\ud800")) def test_subclass_int(self): assert orjson.dumps(SubInt(1)) == b"1" def test_subclass_int_64(self): for val in (9223372036854775807, -9223372036854775807): assert orjson.dumps(SubInt(val)) == str(val).encode("utf-8") def test_subclass_int_53(self): for val in (9007199254740992, -9007199254740992): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubInt(val), option=orjson.OPT_STRICT_INTEGER) def test_subclass_dict(self): assert orjson.dumps(SubDict({"a": "b"})) == b'{"a":"b"}' def test_subclass_list(self): assert orjson.dumps(SubList(["a", "b"])) == b'["a","b"]' ref = [True] * 512 assert orjson.loads(orjson.dumps(SubList(ref))) == ref def test_subclass_float(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubFloat(1.1)) assert json.dumps(SubFloat(1.1)) == "1.1" def test_subclass_tuple(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubTuple((1, 2))) assert json.dumps(SubTuple((1, 2))) == "[1, 2]" def test_namedtuple(self): Point = collections.namedtuple("Point", ["x", "y"]) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(Point(1, 2)) def test_subclass_circular_dict(self): obj = SubDict({}) obj["obj"] = obj with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) def test_subclass_circular_list(self): obj = SubList([]) obj.append(obj) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) def test_subclass_circular_nested(self): obj = SubDict({}) obj["list"] = SubList([{"obj": obj}]) with pytest.raises(orjson.JSONEncodeError): orjson.dumps(obj) class TestSubclassPassthrough: def test_subclass_str(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubStr("zxc"), option=orjson.OPT_PASSTHROUGH_SUBCLASS) def test_subclass_int(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubInt(1), option=orjson.OPT_PASSTHROUGH_SUBCLASS) def test_subclass_dict(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubDict({"a": "b"}), option=orjson.OPT_PASSTHROUGH_SUBCLASS) def test_subclass_list(self): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(SubList(["a", "b"]), option=orjson.OPT_PASSTHROUGH_SUBCLASS) orjson-3.9.15/test/test_transform.py000066400000000000000000000072151456615046100175430ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import pytest import orjson from .util import read_fixture_bytes def _read_file(filename): return read_fixture_bytes(filename, "transform").strip(b"\n").strip(b"\r") class TestJSONTestSuiteTransform: def _pass_transform(self, filename, reference=None): data = _read_file(filename) assert orjson.dumps(orjson.loads(data)) == (reference or data) def _fail_transform(self, filename): data = _read_file(filename) with pytest.raises(orjson.JSONDecodeError): orjson.loads(data) def test_number_1(self): """ number_1.0.json """ self._pass_transform("number_1.0.json") def test_number_1e6(self): """ number_1e6.json """ self._pass_transform("number_1e6.json", b"[1000000.0]") def test_number_1e_999(self): """ number_1e-999.json """ self._pass_transform("number_1e-999.json", b"[0.0]") def test_number_10000000000000000999(self): """ number_10000000000000000999.json """ # cannot serialize due to range assert orjson.loads(_read_file("number_10000000000000000999.json")) == [ 10000000000000000999 ] def test_number_1000000000000000(self): """ number_1000000000000000.json """ self._pass_transform("number_1000000000000000.json") def test_object_key_nfc_nfd(self): """ object_key_nfc_nfd.json """ self._pass_transform("object_key_nfc_nfd.json") def test_object_key_nfd_nfc(self): """ object_key_nfd_nfc.json """ self._pass_transform("object_key_nfd_nfc.json") def test_object_same_key_different_values(self): """ object_same_key_different_values.json """ self._pass_transform("object_same_key_different_values.json", b'{"a":2}') def test_object_same_key_same_value(self): """ object_same_key_same_value.json """ self._pass_transform("object_same_key_same_value.json", b'{"a":1}') def test_object_same_key_unclear_values(self): """ object_same_key_unclear_values.json """ data = _read_file("object_same_key_unclear_values.json") # varies by backend assert data in (b'{"a":-0.0}', b'{"a":0, "a":-0}') def test_string_1_escaped_invalid_codepoint(self): """ string_1_escaped_invalid_codepoint.json """ self._fail_transform("string_1_escaped_invalid_codepoint.json") def test_string_1_invalid_codepoint(self): """ string_1_invalid_codepoint.json """ self._fail_transform("string_1_invalid_codepoint.json") def test_string_2_escaped_invalid_codepoints(self): """ string_2_escaped_invalid_codepoints.json """ self._fail_transform("string_2_escaped_invalid_codepoints.json") def test_string_2_invalid_codepoints(self): """ string_2_invalid_codepoints.json """ self._fail_transform("string_2_invalid_codepoints.json") def test_string_3_escaped_invalid_codepoints(self): """ string_3_escaped_invalid_codepoints.json """ self._fail_transform("string_3_escaped_invalid_codepoints.json") def test_string_3_invalid_codepoints(self): """ string_3_invalid_codepoints.json """ self._fail_transform("string_3_invalid_codepoints.json") def test_string_with_escaped_NULL(self): """ string_with_escaped_NULL.json """ self._pass_transform("string_with_escaped_NULL.json") orjson-3.9.15/test/test_type.py000066400000000000000000000415551456615046100165160ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import io import sys import pytest try: import xxhash except ImportError: xxhash = None import orjson class TestType: def test_fragment(self): """ orjson.JSONDecodeError on fragments """ for val in ("n", "{", "[", "t"): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_invalid(self): """ orjson.JSONDecodeError on invalid """ for val in ('{"age", 44}', "[31337,]", "[,31337]", "[]]", "[,]"): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_str(self): """ str """ for obj, ref in (("blah", b'"blah"'), ("東京", b'"\xe6\x9d\xb1\xe4\xba\xac"')): assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj def test_str_latin1(self): """ str latin1 """ assert orjson.loads(orjson.dumps("üýþÿ")) == "üýþÿ" def test_str_long(self): """ str long """ for obj in ("aaaa" * 1024, "üýþÿ" * 1024, "好" * 1024, "�" * 1024): assert orjson.loads(orjson.dumps(obj)) == obj def test_str_2mib(self): ref = '🐈🐈🐈🐈🐈"üýa0s9999🐈🐈🐈🐈🐈9\0999\\9999' * 1024 * 50 assert orjson.loads(orjson.dumps(ref)) == ref def test_str_very_long(self): """ str long enough to trigger overflow in bytecount """ for obj in ("aaaa" * 20000, "üýþÿ" * 20000, "好" * 20000, "�" * 20000): assert orjson.loads(orjson.dumps(obj)) == obj def test_str_replacement(self): """ str roundtrip � """ assert orjson.dumps("�") == b'"\xef\xbf\xbd"' assert orjson.loads(b'"\xef\xbf\xbd"') == "�" def test_str_trailing_4_byte(self): ref = "うぞ〜😏🙌" assert orjson.loads(orjson.dumps(ref)) == ref def test_str_ascii_control(self): """ worst case format_escaped_str_with_escapes() allocation """ ref = "\x01\x1F" * 1024 * 16 assert orjson.loads(orjson.dumps(ref)) == ref assert orjson.loads(orjson.dumps(ref, option=orjson.OPT_INDENT_2)) == ref def test_str_escape_quote_0(self): assert orjson.dumps('"aaaaaaabb') == b'"\\"aaaaaaabb"' def test_str_escape_quote_1(self): assert orjson.dumps('a"aaaaaabb') == b'"a\\"aaaaaabb"' def test_str_escape_quote_2(self): assert orjson.dumps('aa"aaaaabb') == b'"aa\\"aaaaabb"' def test_str_escape_quote_3(self): assert orjson.dumps('aaa"aaaabb') == b'"aaa\\"aaaabb"' def test_str_escape_quote_4(self): assert orjson.dumps('aaaa"aaabb') == b'"aaaa\\"aaabb"' def test_str_escape_quote_5(self): assert orjson.dumps('aaaaa"aabb') == b'"aaaaa\\"aabb"' def test_str_escape_quote_6(self): assert orjson.dumps('aaaaaa"abb') == b'"aaaaaa\\"abb"' def test_str_escape_quote_7(self): assert orjson.dumps('aaaaaaa"bb') == b'"aaaaaaa\\"bb"' def test_str_escape_quote_8(self): assert orjson.dumps('aaaaaaaab"') == b'"aaaaaaaab\\""' def test_str_escape_quote_multi(self): assert ( orjson.dumps('aa"aaaaabbbbbbbbbbbbbbbbbbbb"bb') == b'"aa\\"aaaaabbbbbbbbbbbbbbbbbbbb\\"bb"' ) def test_str_escape_backslash_0(self): assert orjson.dumps("\\aaaaaaabb") == b'"\\\\aaaaaaabb"' def test_str_escape_backslash_1(self): assert orjson.dumps("a\\aaaaaabb") == b'"a\\\\aaaaaabb"' def test_str_escape_backslash_2(self): assert orjson.dumps("aa\\aaaaabb") == b'"aa\\\\aaaaabb"' def test_str_escape_backslash_3(self): assert orjson.dumps("aaa\\aaaabb") == b'"aaa\\\\aaaabb"' def test_str_escape_backslash_4(self): assert orjson.dumps("aaaa\\aaabb") == b'"aaaa\\\\aaabb"' def test_str_escape_backslash_5(self): assert orjson.dumps("aaaaa\\aabb") == b'"aaaaa\\\\aabb"' def test_str_escape_backslash_6(self): assert orjson.dumps("aaaaaa\\abb") == b'"aaaaaa\\\\abb"' def test_str_escape_backslash_7(self): assert orjson.dumps("aaaaaaa\\bb") == b'"aaaaaaa\\\\bb"' def test_str_escape_backslash_8(self): assert orjson.dumps("aaaaaaaab\\") == b'"aaaaaaaab\\\\"' def test_str_escape_backslash_multi(self): assert ( orjson.dumps("aa\\aaaaabbbbbbbbbbbbbbbbbbbb\\bb") == b'"aa\\\\aaaaabbbbbbbbbbbbbbbbbbbb\\\\bb"' ) def test_str_escape_x32_0(self): assert orjson.dumps("\taaaaaaabb") == b'"\\taaaaaaabb"' def test_str_escape_x32_1(self): assert orjson.dumps("a\taaaaaabb") == b'"a\\taaaaaabb"' def test_str_escape_x32_2(self): assert orjson.dumps("aa\taaaaabb") == b'"aa\\taaaaabb"' def test_str_escape_x32_3(self): assert orjson.dumps("aaa\taaaabb") == b'"aaa\\taaaabb"' def test_str_escape_x32_4(self): assert orjson.dumps("aaaa\taaabb") == b'"aaaa\\taaabb"' def test_str_escape_x32_5(self): assert orjson.dumps("aaaaa\taabb") == b'"aaaaa\\taabb"' def test_str_escape_x32_6(self): assert orjson.dumps("aaaaaa\tabb") == b'"aaaaaa\\tabb"' def test_str_escape_x32_7(self): assert orjson.dumps("aaaaaaa\tbb") == b'"aaaaaaa\\tbb"' def test_str_escape_x32_8(self): assert orjson.dumps("aaaaaaaab\t") == b'"aaaaaaaab\\t"' def test_str_escape_x32_multi(self): assert ( orjson.dumps("aa\taaaaabbbbbbbbbbbbbbbbbbbb\tbb") == b'"aa\\taaaaabbbbbbbbbbbbbbbbbbbb\\tbb"' ) def test_str_emoji(self): ref = "®️" assert orjson.loads(orjson.dumps(ref)) == ref def test_str_emoji_escape(self): ref = '/"®️/"' assert orjson.loads(orjson.dumps(ref)) == ref def test_very_long_list(self): orjson.dumps([[]] * 1024 * 16) def test_very_long_list_pretty(self): orjson.dumps([[]] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_dict(self): orjson.dumps([{}] * 1024 * 16) def test_very_long_dict_pretty(self): orjson.dumps([{}] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_str_empty(self): orjson.dumps([""] * 1024 * 16) def test_very_long_str_empty_pretty(self): orjson.dumps([""] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_str_not_empty(self): orjson.dumps(["a"] * 1024 * 16) def test_very_long_str_not_empty_pretty(self): orjson.dumps(["a"] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_bool(self): orjson.dumps([True] * 1024 * 16) def test_very_long_bool_pretty(self): orjson.dumps([True] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_int(self): orjson.dumps([(2**64) - 1] * 1024 * 16) def test_very_long_int_pretty(self): orjson.dumps([(2**64) - 1] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_very_long_float(self): orjson.dumps([sys.float_info.max] * 1024 * 16) def test_very_long_float_pretty(self): orjson.dumps([sys.float_info.max] * 1024 * 16, option=orjson.OPT_INDENT_2) def test_str_surrogates_loads(self): """ str unicode surrogates loads() """ pytest.raises(orjson.JSONDecodeError, orjson.loads, '"\ud800"') pytest.raises(orjson.JSONDecodeError, orjson.loads, '"\ud83d\ude80"') pytest.raises(orjson.JSONDecodeError, orjson.loads, '"\udcff"') pytest.raises( orjson.JSONDecodeError, orjson.loads, b'"\xed\xa0\xbd\xed\xba\x80"' ) # \ud83d\ude80 def test_str_surrogates_dumps(self): """ str unicode surrogates dumps() """ pytest.raises(orjson.JSONEncodeError, orjson.dumps, "\ud800") pytest.raises(orjson.JSONEncodeError, orjson.dumps, "\ud83d\ude80") pytest.raises(orjson.JSONEncodeError, orjson.dumps, "\udcff") pytest.raises(orjson.JSONEncodeError, orjson.dumps, {"\ud83d\ude80": None}) pytest.raises( orjson.JSONEncodeError, orjson.dumps, b"\xed\xa0\xbd\xed\xba\x80" ) # \ud83d\ude80 @pytest.mark.skipif( xxhash is None, reason="xxhash install broken on win, python3.9, Azure" ) def test_str_ascii(self): """ str is ASCII but not compact """ digest = xxhash.xxh32_hexdigest("12345") for _ in range(2): assert orjson.dumps(digest) == b'"b30d56b4"' def test_bytes_dumps(self): """ bytes dumps not supported """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps([b"a"]) def test_bytes_loads(self): """ bytes loads """ assert orjson.loads(b"[]") == [] def test_bytearray_loads(self): """ bytearray loads """ arr = bytearray() arr.extend(b"[]") assert orjson.loads(arr) == [] def test_memoryview_loads(self): """ memoryview loads """ arr = bytearray() arr.extend(b"[]") assert orjson.loads(memoryview(arr)) == [] def test_bytesio_loads(self): """ memoryview loads """ arr = io.BytesIO(b"[]") assert orjson.loads(arr.getbuffer()) == [] def test_bool(self): """ bool """ for obj, ref in ((True, "true"), (False, "false")): assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == obj def test_bool_true_array(self): """ bool true array """ obj = [True] * 256 ref = ("[" + ("true," * 255) + "true]").encode("utf-8") assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj def test_bool_false_array(self): """ bool false array """ obj = [False] * 256 ref = ("[" + ("false," * 255) + "false]").encode("utf-8") assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj def test_none(self): """ null """ obj = None ref = "null" assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == obj def test_int(self): """ int compact and non-compact """ obj = [-5000, -1000, -10, -5, -2, -1, 0, 1, 2, 5, 10, 1000, 50000] ref = b"[-5000,-1000,-10,-5,-2,-1,0,1,2,5,10,1000,50000]" assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj def test_null_array(self): """ null array """ obj = [None] * 256 ref = ("[" + ("null," * 255) + "null]").encode("utf-8") assert orjson.dumps(obj) == ref assert orjson.loads(ref) == obj def test_nan_dumps(self): """ NaN serializes to null """ assert orjson.dumps(float("NaN")) == b"null" def test_nan_loads(self): """ NaN is not valid JSON """ with pytest.raises(orjson.JSONDecodeError): orjson.loads("[NaN]") with pytest.raises(orjson.JSONDecodeError): orjson.loads("[nan]") def test_infinity_dumps(self): """ Infinity serializes to null """ assert orjson.dumps(float("Infinity")) == b"null" def test_infinity_loads(self): """ Infinity, -Infinity is not valid JSON """ with pytest.raises(orjson.JSONDecodeError): orjson.loads("[infinity]") with pytest.raises(orjson.JSONDecodeError): orjson.loads("[Infinity]") with pytest.raises(orjson.JSONDecodeError): orjson.loads("[-Infinity]") with pytest.raises(orjson.JSONDecodeError): orjson.loads("[-infinity]") def test_int_53(self): """ int 53-bit """ for val in (9007199254740991, -9007199254740991): assert orjson.loads(str(val)) == val assert orjson.dumps(val, option=orjson.OPT_STRICT_INTEGER) == str( val ).encode("utf-8") def test_int_53_exc(self): """ int 53-bit exception on 64-bit """ for val in (9007199254740992, -9007199254740992): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(val, option=orjson.OPT_STRICT_INTEGER) def test_int_53_exc_usize(self): """ int 53-bit exception on 64-bit usize """ for val in (9223372036854775808, 18446744073709551615): with pytest.raises(orjson.JSONEncodeError): orjson.dumps(val, option=orjson.OPT_STRICT_INTEGER) def test_int_64(self): """ int 64-bit """ for val in (9223372036854775807, -9223372036854775807): assert orjson.loads(str(val)) == val assert orjson.dumps(val) == str(val).encode("utf-8") def test_uint_64(self): """ uint 64-bit """ for val in (0, 9223372036854775808, 18446744073709551615): assert orjson.loads(str(val)) == val assert orjson.dumps(val) == str(val).encode("utf-8") def test_int_128(self): """ int 128-bit """ for val in (18446744073709551616, -9223372036854775809): pytest.raises(orjson.JSONEncodeError, orjson.dumps, val) def test_float(self): """ float """ assert -1.1234567893 == orjson.loads("-1.1234567893") assert -1.234567893 == orjson.loads("-1.234567893") assert -1.34567893 == orjson.loads("-1.34567893") assert -1.4567893 == orjson.loads("-1.4567893") assert -1.567893 == orjson.loads("-1.567893") assert -1.67893 == orjson.loads("-1.67893") assert -1.7893 == orjson.loads("-1.7893") assert -1.893 == orjson.loads("-1.893") assert -1.3 == orjson.loads("-1.3") assert 1.1234567893 == orjson.loads("1.1234567893") assert 1.234567893 == orjson.loads("1.234567893") assert 1.34567893 == orjson.loads("1.34567893") assert 1.4567893 == orjson.loads("1.4567893") assert 1.567893 == orjson.loads("1.567893") assert 1.67893 == orjson.loads("1.67893") assert 1.7893 == orjson.loads("1.7893") assert 1.893 == orjson.loads("1.893") assert 1.3 == orjson.loads("1.3") def test_float_precision_loads(self): """ float precision loads() """ assert orjson.loads("31.245270191439438") == 31.245270191439438 assert orjson.loads("-31.245270191439438") == -31.245270191439438 assert orjson.loads("121.48791951161945") == 121.48791951161945 assert orjson.loads("-121.48791951161945") == -121.48791951161945 assert orjson.loads("100.78399658203125") == 100.78399658203125 assert orjson.loads("-100.78399658203125") == -100.78399658203125 def test_float_precision_dumps(self): """ float precision dumps() """ assert orjson.dumps(31.245270191439438) == b"31.245270191439438" assert orjson.dumps(-31.245270191439438) == b"-31.245270191439438" assert orjson.dumps(121.48791951161945) == b"121.48791951161945" assert orjson.dumps(-121.48791951161945) == b"-121.48791951161945" assert orjson.dumps(100.78399658203125) == b"100.78399658203125" assert orjson.dumps(-100.78399658203125) == b"-100.78399658203125" def test_float_edge(self): """ float edge cases """ assert orjson.dumps(0.8701) == b"0.8701" assert orjson.loads("0.8701") == 0.8701 assert ( orjson.loads("0.0000000000000000000000000000000000000000000000000123e50") == 1.23 ) assert orjson.loads("0.4e5") == 40000.0 assert orjson.loads("0.00e-00") == 0.0 assert orjson.loads("0.4e-001") == 0.04 assert orjson.loads("0.123456789e-12") == 1.23456789e-13 assert orjson.loads("1.234567890E+34") == 1.23456789e34 assert orjson.loads("23456789012E66") == 2.3456789012e76 def test_float_notation(self): """ float notation """ for val in ("1.337E40", "1.337e+40", "1337e40", "1.337E-4"): obj = orjson.loads(val) assert obj == float(val) assert orjson.dumps(val) == ('"%s"' % val).encode("utf-8") def test_list(self): """ list """ obj = ["a", "😊", True, {"b": 1.1}, 2] ref = '["a","😊",true,{"b":1.1},2]' assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == obj def test_tuple(self): """ tuple """ obj = ("a", "😊", True, {"b": 1.1}, 2) ref = '["a","😊",true,{"b":1.1},2]' assert orjson.dumps(obj) == ref.encode("utf-8") assert orjson.loads(ref) == list(obj) def test_object(self): """ object() dumps() """ with pytest.raises(orjson.JSONEncodeError): orjson.dumps(object()) orjson-3.9.15/test/test_typeddict.py000066400000000000000000000007051456615046100175160ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import orjson try: from typing import TypedDict # type: ignore except ImportError: from typing_extensions import TypedDict class TestTypedDict: def test_typeddict(self): """ dumps() TypedDict """ class TypedDict1(TypedDict): a: str b: int obj = TypedDict1(a="a", b=1) assert orjson.dumps(obj) == b'{"a":"a","b":1}' orjson-3.9.15/test/test_ujson.py000066400000000000000000000250251456615046100166650ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import json import pytest import orjson class TestUltraJSON: def test_doubleLongIssue(self): sut = {"a": -4342969734183514} encoded = orjson.dumps(sut) decoded = orjson.loads(encoded) assert sut == decoded encoded = orjson.dumps(sut) decoded = orjson.loads(encoded) assert sut == decoded def test_doubleLongDecimalIssue(self): sut = {"a": -12345678901234.56789012} encoded = orjson.dumps(sut) decoded = orjson.loads(encoded) assert sut == decoded encoded = orjson.dumps(sut) decoded = orjson.loads(encoded) assert sut == decoded def test_encodeDecodeLongDecimal(self): sut = {"a": -528656961.4399388} encoded = orjson.dumps(sut) orjson.loads(encoded) def test_decimalDecodeTest(self): sut = {"a": 4.56} encoded = orjson.dumps(sut) decoded = orjson.loads(encoded) pytest.approx(sut["a"], decoded["a"]) def test_encodeDictWithUnicodeKeys(self): val = { "key1": "value1", "key1": "value1", "key1": "value1", "key1": "value1", "key1": "value1", "key1": "value1", } orjson.dumps(val) val = { "بن": "value1", "بن": "value1", "بن": "value1", "بن": "value1", "بن": "value1", "بن": "value1", "بن": "value1", } orjson.dumps(val) def test_encodeArrayOfNestedArrays(self): val = [[[[]]]] * 20 # type: ignore output = orjson.dumps(val) assert val == orjson.loads(output) assert val == orjson.loads(output) def test_encodeArrayOfDoubles(self): val = [31337.31337, 31337.31337, 31337.31337, 31337.31337] * 10 output = orjson.dumps(val) assert val == orjson.loads(output) assert val == orjson.loads(output) def test_encodeStringConversion2(self): val = "A string \\ / \b \f \n \r \t" output = orjson.dumps(val) assert val == orjson.loads(output) assert output == b'"A string \\\\ / \\b \\f \\n \\r \\t"' assert val == orjson.loads(output) def test_decodeUnicodeConversion(self): pass def test_encodeUnicodeConversion1(self): val = "Räksmörgås اسامة بن محمد بن عوض بن لادن" enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def test_encodeControlEscaping(self): val = "\x19" enc = orjson.dumps(val) dec = orjson.loads(enc) assert val == dec assert enc == orjson.dumps(val) def test_encodeUnicodeConversion2(self): val = "\xe6\x97\xa5\xd1\x88" enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def test_encodeUnicodeSurrogatePair(self): val = "\xf0\x90\x8d\x86" enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def test_encodeUnicode4BytesUTF8(self): val = "\xf0\x91\x80\xb0TRAILINGNORMAL" enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def test_encodeUnicode4BytesUTF8Highest(self): val = "\xf3\xbf\xbf\xbfTRAILINGNORMAL" enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def testEncodeUnicodeBMP(self): s = "\U0001f42e\U0001f42e\U0001F42D\U0001F42D" # 🐮🐮🐭🐭 orjson.dumps(s) json.dumps(s) assert json.loads(json.dumps(s)) == s assert orjson.loads(orjson.dumps(s)) == s def testEncodeSymbols(self): s = "\u273f\u2661\u273f" # ✿♡✿ encoded = orjson.dumps(s) encoded_json = json.dumps(s) decoded = orjson.loads(encoded) assert s == decoded encoded = orjson.dumps(s) # json outputs an unicode object encoded_json = json.dumps(s, ensure_ascii=False) assert encoded == encoded_json.encode("utf-8") decoded = orjson.loads(encoded) assert s == decoded def test_encodeArrayInArray(self): val = [[[[]]]] # type: ignore output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeIntConversion(self): val = 31337 output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeIntNegConversion(self): val = -31337 output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeLongNegConversion(self): val = -9223372036854775808 output = orjson.dumps(val) orjson.loads(output) orjson.loads(output) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeListConversion(self): val = [1, 2, 3, 4] output = orjson.dumps(val) assert val == orjson.loads(output) assert val == orjson.loads(output) def test_encodeDictConversion(self): val = {"k1": 1, "k2": 2, "k3": 3, "k4": 4} output = orjson.dumps(val) assert val == orjson.loads(output) assert val == orjson.loads(output) assert val == orjson.loads(output) def test_encodeNoneConversion(self): val = None output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeTrueConversion(self): val = True output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeFalseConversion(self): val = False output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) def test_encodeToUTF8(self): val = b"\xe6\x97\xa5\xd1\x88".decode("utf-8") enc = orjson.dumps(val) dec = orjson.loads(enc) assert enc == orjson.dumps(val) assert dec == orjson.loads(enc) def test_decodeFromUnicode(self): val = '{"obj": 31337}' dec1 = orjson.loads(val) dec2 = orjson.loads(str(val)) assert dec1 == dec2 def test_decodeJibberish(self): val = "fdsa sda v9sa fdsa" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenArrayStart(self): val = "[" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenObjectStart(self): val = "{" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenArrayEnd(self): val = "]" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenObjectEnd(self): val = "}" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeObjectDepthTooBig(self): val = "{" * (1024 * 1024) pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeStringUnterminated(self): val = '"TESTING' pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeStringUntermEscapeSequence(self): val = '"TESTING\\"' pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeStringBadEscape(self): val = '"TESTING\\"' pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeTrueBroken(self): val = "tru" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeFalseBroken(self): val = "fa" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeNullBroken(self): val = "n" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenDictKeyTypeLeakTest(self): val = '{{1337:""}}' for _ in range(1000): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenDictLeakTest(self): val = '{{"key":"}' for _ in range(1000): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeBrokenListLeakTest(self): val = "[[[true" for _ in range(1000): pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeDictWithNoKey(self): val = "{{{{31337}}}}" pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeDictWithNoColonOrValue(self): val = '{{{{"key"}}}}' pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeDictWithNoValue(self): val = '{{{{"key":}}}}' pytest.raises(orjson.JSONDecodeError, orjson.loads, val) def test_decodeNumericIntPos(self): val = "31337" assert 31337 == orjson.loads(val) def test_decodeNumericIntNeg(self): assert -31337 == orjson.loads("-31337") def test_encodeNullCharacter(self): val = "31337 \x00 1337" output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) val = "\x00" output = orjson.dumps(val) assert val == orjson.loads(output) assert output == orjson.dumps(val) assert val == orjson.loads(output) assert b'" \\u0000\\r\\n "' == orjson.dumps(" \u0000\r\n ") def test_decodeNullCharacter(self): val = '"31337 \\u0000 31337"' assert orjson.loads(val) == json.loads(val) def test_decodeEscape(self): base = "\u00e5".encode() quote = b'"' val = quote + base + quote assert json.loads(val) == orjson.loads(val) def test_decodeBigEscape(self): for _ in range(10): base = "\u00e5".encode() quote = b'"' val = quote + (base * 1024 * 1024 * 2) + quote assert json.loads(val) == orjson.loads(val) orjson-3.9.15/test/test_uuid.py000066400000000000000000000065651456615046100165050ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import uuid import pytest import orjson class TestUUID: def test_uuid_immutable(self): """ UUID objects are immutable """ val = uuid.uuid4() with pytest.raises(TypeError): val.int = 1 # type: ignore with pytest.raises(TypeError): val.int = None # type: ignore def test_uuid_int(self): """ UUID.int is a 128-bit integer """ val = uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece") assert isinstance(val.int, int) assert val.int >= 2**64 assert val.int < 2**128 assert val.int, 151546616840194781678008611711208857294 def test_uuid_overflow(self): """ UUID.int can't trigger errors in _PyLong_AsByteArray """ with pytest.raises(ValueError): uuid.UUID(int=2**128) with pytest.raises(ValueError): uuid.UUID(int=-1) def test_uuid_subclass(self): """ UUID subclasses are not serialized """ class AUUID(uuid.UUID): pass with pytest.raises(orjson.JSONEncodeError): orjson.dumps(AUUID("{12345678-1234-5678-1234-567812345678}")) def test_serializes_withopt(self): """ dumps() accepts deprecated OPT_SERIALIZE_UUID """ assert ( orjson.dumps( uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"), option=orjson.OPT_SERIALIZE_UUID, ) == b'"7202d115-7ff3-4c81-a7c1-2a1f067b1ece"' ) def test_nil_uuid(self): assert ( orjson.dumps(uuid.UUID("00000000-0000-0000-0000-000000000000")) == b'"00000000-0000-0000-0000-000000000000"' ) def test_all_ways_to_create_uuid_behave_equivalently(self): # Note that according to the docstring for the uuid.UUID class, all the # forms below are equivalent -- they end up with the same value for # `self.int`, which is all that really matters uuids = [ uuid.UUID("{12345678-1234-5678-1234-567812345678}"), uuid.UUID("12345678123456781234567812345678"), uuid.UUID("urn:uuid:12345678-1234-5678-1234-567812345678"), uuid.UUID(bytes=b"\x12\x34\x56\x78" * 4), uuid.UUID( bytes_le=b"\x78\x56\x34\x12\x34\x12\x78\x56" + b"\x12\x34\x56\x78\x12\x34\x56\x78" ), uuid.UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)), uuid.UUID(int=0x12345678123456781234567812345678), ] result = orjson.dumps(uuids) canonical_uuids = ['"%s"' % str(u) for u in uuids] serialized = ("[%s]" % ",".join(canonical_uuids)).encode("utf8") assert result == serialized def test_serializes_correctly_with_leading_zeroes(self): instance = uuid.UUID(int=0x00345678123456781234567812345678) assert orjson.dumps(instance) == ('"%s"' % str(instance)).encode("utf8") def test_all_uuid_creation_functions_create_serializable_uuids(self): uuids = ( uuid.uuid1(), uuid.uuid3(uuid.NAMESPACE_DNS, "python.org"), uuid.uuid4(), uuid.uuid5(uuid.NAMESPACE_DNS, "python.org"), ) for val in uuids: assert orjson.dumps(val) == f'"{val}"'.encode("utf-8") orjson-3.9.15/test/util.py000066400000000000000000000016641456615046100154500ustar00rootroot00000000000000# SPDX-License-Identifier: (Apache-2.0 OR MIT) import lzma import os from pathlib import Path from typing import Any, Dict import orjson dirname = os.path.join(os.path.dirname(__file__), "../data") STR_CACHE: Dict[str, str] = {} OBJ_CACHE: Dict[str, Any] = {} def read_fixture_bytes(filename, subdir=None): if subdir is None: path = Path(dirname, filename) else: path = Path(dirname, subdir, filename) if path.suffix == ".xz": contents = lzma.decompress(path.read_bytes()) else: contents = path.read_bytes() return contents def read_fixture_str(filename, subdir=None): if filename not in STR_CACHE: STR_CACHE[filename] = read_fixture_bytes(filename, subdir).decode("utf-8") return STR_CACHE[filename] def read_fixture_obj(filename): if filename not in OBJ_CACHE: OBJ_CACHE[filename] = orjson.loads(read_fixture_str(filename)) return OBJ_CACHE[filename]