Skip to content

Native Result.to_json(): write text outside ASCII as it is, as the JVM build does - #495

Merged
tae898 merged 1 commit into
mainfrom
fix/454-to-json-raw-utf8
Nov 26, 2026
Merged

tae898 merged 1 commit into
mainfrom
fix/454-to-json-raw-utf8

Conversation

@tae898

@tae898 tae898 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Result.to_json() of the same row was different text on the two packages. arcadedb-jvm writes a character outside ASCII as it is, and arcadedb wrote it as a \u escape, so the length, the bytes, and a hash of the text differed. The native build now writes the character as it is too. It keeps a \u escape only where the JVM build has one (control characters, U+2028, and U+2029), and for a lone surrogate, which has no UTF-8 form. The parsed values do not change.

For a row with one string property:

package to_json()
arcadedb before {"s":"caf\u00e9 \ud83d\ude00"}
arcadedb after {"s":"café 😀"}
arcadedb-jvm {"s":"café 😀"}

Related issues

Closes #454. Refs #314.

Performance changes

None claimed, and I did not time it.

Docs

upgrading.adoc states the changed text under changed behaviour, and databases-and-queries.adoc says how to_json() writes a string.

Checklist

  • A regression test fails on the old code and passes on the new (test_to_json_text_outside_ascii_golden runs on both wheels in CI; the old native call writes the escapes shown above, which the expected text does not have)
  • The test suite that the change can affect passes (CI)
  • uvx pre-commit run --files <changed files> passes

…M build does

The JVM build's to_json() is the engine's writer: a character outside ASCII is
written as it is. The native build used json.dumps with its default
ensure_ascii, so the same row was a different, longer text.

It now writes with ensure_ascii=False and escapes U+2028, U+2029 and lone
surrogates afterwards, so the text matches the JVM build and always has a
UTF-8 form. A golden test with two, three and four byte characters runs on
both wheels. The upgrade page states the changed text.
@tae898 tae898 added bug Something isn't working python Pull requests that update python code native The arcadedb package (native library build) labels Nov 26, 2026
@tae898 tae898 self-assigned this Nov 26, 2026
@tae898
tae898 merged commit 09bf61b into main Nov 26, 2026
26 checks passed
@tae898
tae898 deleted the fix/454-to-json-raw-utf8 branch November 26, 2026 20:53
@github-actions github-actions Bot added this to the 26.12.1 milestone Nov 26, 2026
@tae898 tae898 mentioned this pull request Nov 30, 2026
1 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working native The arcadedb package (native library build) python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-ASCII text in Result.to_json(): raw UTF-8 on the JVM wheel, escaped on the native wheel

1 participant