json.go
json.go - Overview
This file provides utility functions for parsing JSON paths, determining whether they use legacy or JSONPath syntax.
Detailed Documentation
Function: ParseInputJSONPath
Purpose: This function parses a given JSON path string to determine whether it follows the legacy path syntax or JSONPath syntax. It also handles a special case where the path is simply ".".
Parameters:
path
(string): The JSON path string to parse.
Returns:
string
: The potentially modified JSON path.bool
: A boolean value indicating whether the path uses legacy syntax (true
) or JSONPath syntax (false
).
func ParseInputJSONPath(path string) (string, bool) {
isLegacyPath := path[0] != '$'
// Handle . path error
if len(path) == 1 && path[0] == '.' {
path = "$"
}
return path, isLegacyPath
}