From ab5012e0083ff6623ffab78f52f9ea1120d80ffb Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 11 Aug 2026 14:26:17 +0200 Subject: jsonmatch: write down idea for func CapturedField --- jsonmatch/interface.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'jsonmatch') diff --git a/jsonmatch/interface.go b/jsonmatch/interface.go index 73b05ef..f36967a 100644 --- a/jsonmatch/interface.go +++ b/jsonmatch/interface.go @@ -268,6 +268,15 @@ func CaptureField[T any](target *T) any { return capturedField{target} } +// TODO: func CapturedField[T any](target *T) any +// +// -> idea: in a large JSON structure, a key may be defined in one place and then used in another; +// CaptureField() picks it up at the declaration place and then CapturedField() with the same pointer is used at the reference site; +// during traversal, jsonmatch "remembers" all CaptureField() calls, and also stalls validation of CapturedField() for later, +// after traversal, CapturedField() instances are checked to see if they actually had the expected value +// -> problem: invocations of CaptureField() and CapturedField() look very similar +// -> idea: CaptureField() returns an object, and then we can call field.Ref() at the reference site + type capturedField struct { PointerToTarget any } -- cgit v1.3.1