Class JsonScalarLocator
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA located scalar: where it is, what it is, and how confidently we found it.static final recordDiagnostic record of what the structural parser reported versus what was verified.static enumThe four JSON scalar types (SRS section 3, "Scalar"). -
Method Summary
-
Method Details
-
locate
Finds the scalar attarget.The whole document is always scanned, even after the target is found, because duplicate property names anywhere in the document are a fatal ambiguity (SRS section 7.1 rule 8).
- Throws:
SpliceException-ErrorCode.PATH_MISSINGif the path does not resolve,ErrorCode.NON_SCALARif it resolves to an object or array,ErrorCode.DUPLICATE_JSON_KEYon a duplicate property name,ErrorCode.PARSE_FAILEDon malformed input
-