Reusing a ProtoJSON message: demonstrate merge and replacement separately
Choose object lifetime according to replacement or patch intent, then check field presence.
Why an earlier input survives
Distinguish the parser’s merge contract from a screen’s replacement intent. If a field absent from the new input remains in the reused output object, inspect object lifetime and initialization. Include actual field presence in the observations supplied to Truthound; an old note can otherwise appear to be the new user’s input. [1, 2, 3]
A documentation request, not a behavior change
Protobuf #30822 requests clarification that JsonStringToMessage merges into its output message. Comments lead to a documentation PR, not an established change to replacement semantics. Keep the ambiguous name, the existing merge behavior and documentation publication as distinct facts. [1]
Use object lifetime as the control
Parse the same second JSON into a fresh object and a reused object. Withhold replacement-screen completion when omitted fields retain a previous user’s values. Keep parser options and input constant while changing construction or initialization. Separate actual presence from a displayed default; an empty display is not proof of field removal. [1, 3]
The second call sends only red
In the illustrative first input, color=blue and note=old; the second provides only color=red. Under full replacement, expected note presence is 0. Observed presence 0 meets that condition. A retained old note gives 1 and fails because merge was used as replacement. With patch intent, retaining the note can be correct, requiring a different expected value. [1, 3]
Check extracted presence
Truthound Core Python SDK 3.3.2 can compare replacement_old_field_present and old_optional_field_present using ColumnPairValidator with relationship="==". The operator extracts both as non-missing 0 or 1 values instead of inferring them from parser success. The SDK does not initialize Protobuf objects or change merge semantics. [1, 2, 3]
Choose replacement or patch deliberately
For replacement, test a fresh message or explicit initialization before parsing. For a patch, retain merge and define omission, explicit NULL and defaults against the actual API version. An absent JSON field is not universally a deletion request. Show storage completion only after checking the chosen intent. [1, 3]
Application conditions
Confirm the actual API version’s merge contract, distinguish replacement from patch intent and extract field presence.
Alternatives
For replacement, test a fresh or explicitly initialized message before parsing; retain merge for a patch.
Limitations
Truthound does not change parser behavior or interpret every omitted JSON field as a deletion.
Evidence
- Event checked
- Subject checked
- Modified
