json: fix recursive pointer encoding #19840
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #19812
🤖 Generated by Copilot at fff005f
This pull request fixes and tests the JSON encoding and decoding of structs with optional and recursive pointer fields in
vlib/v/gen/c/json.v
andvlib/json
. It adds a type check, removes a variable prefix, and creates a new test filevlib/json/json_encode_recursive_ptr_test.v
.🤖 Generated by Copilot at fff005f
vlib/json/json_encode_recursive_ptr_test.v
that checks the JSON encoding of a struct with a recursive pointer field of type?&PostTag
(link)vlib/v/gen/c/json.v
to handle optional fields with pointer types differently from non-pointer types (link)vlib/v/gen/c/json.v
to remove the unnecessaryres
prefix from the variable name that holds the decoded value of the optional field (link)