Skip to content

feat(http): treat null JsonFormat fields as absent#6863

Merged
lvs0075 merged 1 commit into
tronprotocol:release_v4.8.2from
halibobo1205:codex/fix-json-null-4.8.2
Jul 2, 2026
Merged

feat(http): treat null JsonFormat fields as absent#6863
lvs0075 merged 1 commit into
tronprotocol:release_v4.8.2from
halibobo1205:codex/fix-json-null-4.8.2

Conversation

@halibobo1205

@halibobo1205 halibobo1205 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator
  1. Treat known protobuf fields with literal null as absent so HTTP APIs recover the 4.8.1 fastjson-compatible behavior for null object fields.

  2. This relaxes JSON-RPC buildTransaction ABI handling because that path now accepts null ABI fields instead of returning invalid abi.

  3. Existing array-element behavior is unchanged: null elements in repeated message/object arrays remain invalid, while null elements in repeated primitive/bytes/enum arrays are consumed and skipped by the legacy parser.
    fix: [Feature] Replace fastjson with Jackson #6607 (comment)

1. Treat known protobuf fields with literal null as absent so HTTP APIs recover the 4.8.1 fastjson-compatible behavior for null object fields.

2. This relaxes JSON-RPC buildTransaction ABI handling because that path now accepts null ABI fields instead of returning invalid abi.

3. TRON's JsonFormat now aligns more closely with protobuf Java JsonFormat: field-level null is treated as absent, while null elements inside repeated arrays remain invalid.
@github-actions github-actions Bot requested review from Sunny6889 and bladehan1 July 2, 2026 06:41
@halibobo1205 halibobo1205 added the topic:api rpc/http related issue label Jul 2, 2026
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Jul 2, 2026
@lvs0075 lvs0075 requested a review from waynercheung July 2, 2026 06:42
@Sunny6889

Copy link
Copy Markdown
Contributor

Nice fix on the inbound side. One gap worth a follow-up: this only covers the inbound (parse) side. The
outbound (serialize) side still emits "field":nullorg.tron.json's toJSONString() serializes null fields as "field":null, because@JsonInclude(NON_NULL) applies to POJO serialization only, not toJsonNode/tree-model serialization (NullNode is written as-is).

It's functionally fine now (the parser tolerates null), but the response JSON shape still diverges from the old fastjson behavior: fastjson omitted null-valued fields by default, whereas the current output keeps them. Downstream tools that migrated assuming "fastjson omits nulls" will see extra"field":null` entries in node responses.

To fully restore fastjson output compatibility, we'd also need to strip NullNode on the org.tron.json serialization side (prune null object fields before writeValueAsString).

@halibobo1205

Copy link
Copy Markdown
Collaborator Author

@Sunny6889
Good point in general: JsonInclude.NON_NULL does not prune NullNode values from Jackson tree nodes.

That said, in the current HTTP response paths, I did not find a production path that inserts NullNode into org.tron.json.JSONObject, or parses arbitrary explicit-null JSON and returns it directly. Most outbound JSONObject usage wraps JsonFormat.printToString(proto, ...), and that printer does not emit JSON null fields. Also, JSONObject.put(key, null) removes the key.

So I agree this is a valid compatibility caveat for the wrapper. However, I would treat it as a follow-up compatibility-hardening item rather than a blocker for this inbound JsonFormat fix.

@waynercheung waynercheung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lvs0075 lvs0075 merged commit b562449 into tronprotocol:release_v4.8.2 Jul 2, 2026
15 checks passed
@halibobo1205 halibobo1205 linked an issue Jul 2, 2026 that may be closed by this pull request
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:api rpc/http related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Replace fastjson with Jackson

5 participants