You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "chaokunyang (via GitHub)" <gi...@apache.org> on 2026/08/23 11:03:43 UTC
[PR] feat(java): parse quoted JSON scalar values [fory]
chaokunyang opened a new pull request, #3967:
URL: https://github.com/apache/fory/pull/3967
<!--
**Thanks for contributing to Apache Fory™.**
**If this is your first time opening a PR on fory, you can refer to [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory™** community has requirements on the naming of pr titles. You can also find instructions in [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Apache Fory™ has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here.
-->
## Why?
Financial and other APIs commonly encode boolean and numeric values as JSON strings. Fory JSON
previously rejected those values for declared scalar targets, so users had to register custom
codecs even for standard types such as `BigDecimal`.
## What does this PR do?
- Accept quoted ordinary token text for declared boolean, byte, short, int, long, float, double,
`BigInteger`, and `BigDecimal` targets without a configuration switch.
- Parse quoted values through the same representation-specific token parsers as native JSON
tokens, without allocating an intermediate `String` or another per-value carrier.
- Keep natural dynamic JSON typing: a quoted value read as `Object` remains a `String`; a quoted
numeric value read as `Number` is a `Double`.
- Cover roots, generated and interpreted object codecs, arrays, collections, maps, Latin1, UTF-8,
UTF-16, arbitrary-precision limits, and malformed quoted input.
- Document the user-visible coercion behavior.
## Related issues
N/A.
## AI Contribution Checklist
<!-- Full requirements and disclosure template:
https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs -->
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review` summary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described in `AI_POLICY.md`, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.
<!-- If substantial AI assistance = `yes`, paste the completed checklist and disclosure block here, including the final ai_review summary and screenshot evidence or equivalent persisted links from both fresh reviewers described in AI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes. -->
## Does this PR introduce any user-facing change?
Yes. Declared boolean and numeric JSON targets now accept their ordinary token text inside a JSON
string. Serialization output remains unchanged.
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
Environment: macOS arm64, OpenJDK 25.0.3, JMH 1.37, one fork/thread, `-Xms2g -Xmx2g`, one-second
iterations, and `-prof gc`.
Unquoted generated primitive POJO parsing against the exact merge-base artifact:
| Input | Baseline | Current | Change | Allocation |
| --- | ---: | ---: | ---: | ---: |
| Latin1 | 60.159 ns/op | 58.797 ns/op | -2.263% | 40.000 / 40.000 B/op |
| UTF-8 | 56.840 ns/op | 55.550 ns/op | -2.270% | 40.000 / 40.000 B/op |
| UTF-16 | 131.191 ns/op | 133.706 ns/op | +1.917% | 40.001 / 40.001 B/op |
Quoted and unquoted normalized allocations are equal to JMH counter precision:
| Case | Unquoted | Quoted |
| --- | ---: | ---: |
| `BigDecimal` | 184.001 B/op | 184.001 B/op |
| `BigInteger` | 264.001 B/op | 264.002 B/op |
| Combined scalar POJO | 592.003 B/op | 592.003 B/op |
Final-head targeted validation:
```text
ENABLE_FORY_DEBUG_OUTPUT=1 mvn -q -pl fory-json -Dtest=JsonScalarTest \
spotless:check checkstyle:check test
```
139 tests passed with no failures, errors, or skips.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] feat(java): parse quoted JSON scalar values [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang merged PR #3967:
URL: https://github.com/apache/fory/pull/3967
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org