Class JsonScalarLocator

java.lang.Object
io.jenkins.plugins.configsplice.engine.json.JsonScalarLocator

public final class JsonScalarLocator extends Object
Locates the exact source range of a JSON scalar addressed by a JsonPath (SRS sections 7.1 and 10.1).

Why locate-then-splice, and why a hybrid

Reading the document into a tree and writing it back would destroy comments, indentation, key order and newline style. So the parser is used only to understand the document; the bytes are edited in place.

Jackson reports where a token started, but the position it reports after reading a token is not reliably the token's last character: for unterminated-by-nature tokens such as numbers, the scanner must look at the following delimiter before it knows the number ended. So the end offset is computed lexically here, and the resulting candidate range is then verified by decoding it and comparing against the value Jackson itself parsed. A range only becomes a splice target once the two agree, which means a change in Jackson's offset conventions can make this class fail loudly but cannot make it corrupt a file.