aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-08-11 14:26:17 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-08-11 14:26:17 +0200
commitab5012e0083ff6623ffab78f52f9ea1120d80ffb (patch)
tree418653bccf42c6e8849828532e1952db23698f17
parent2d21cde4673452e77c9c3b8ba55dc2cff8709368 (diff)
downloadgo-gg-ab5012e0083ff6623ffab78f52f9ea1120d80ffb.tar.gz
jsonmatch: write down idea for func CapturedField
-rw-r--r--jsonmatch/interface.go9
1 files changed, 9 insertions, 0 deletions
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
}