Skip to content

fix: accept single-quoted string args in path functions (#1078) - #1080

Open
arimu1 wants to merge 1 commit into
json-path:masterfrom
arimu1:fix/1078-single-quoted-path-function-args
Open

fix: accept single-quoted string args in path functions (#1078)#1080
arimu1 wants to merge 1 commit into
json-path:masterfrom
arimu1:fix/1078-single-quoted-path-function-args

Conversation

@arimu1

@arimu1 arimu1 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Fixes #1078

Path function argument parsing only treated double-quoted strings as JSON parameters. Single-quoted string args were dropped ($.concat('hello') → empty) or corrupted when mixed with path args ($.concat($.x,'-',$.y)P-'Q). Filter predicates already accept single quotes.

Changes

  • Treat SINGLE_QUOTE like a JSON parameter starter in PathCompiler.parseFunctionParameters
  • Track the active quote delimiter (not a shared counter) so apostrophes inside double-quoted strings (e.g. "it's") still group correctly
  • Normalize single-quoted string literals to double-quoted JSON before JsonProvider.parse, so strict providers (Jackson, Jakarta JSON, etc.) accept them

Tests

  • NestedFunctionTest.testStringConcatWithSingleQuotedJSONParameter covers standalone, mixed path+literal, and double-quoted apostrophe cases across all configured providers

Test plan

  • ./gradlew :json-path:test --tests com.jayway.jsonpath.internal.function.NestedFunctionTest.testStringConcatWithSingleQuotedJSONParameter (Temurin 21)
  • ./gradlew :json-path:test full module suite (Temurin 21)
JsonPath.read("{}", "$.concat('hello')");                 // "hello"
JsonPath.read("{\"x\":\"P\",\"y\":\"Q\"}", "$.concat($.x,'-',$.y)"); // "P-Q"
JsonPath.read("{}", "$.concat(\"it's\")");                // "it's"

Recognize single-quoted string literals as JSON function parameters and
track the active quote delimiter so mixed quotes group correctly.
Normalize single-quoted literals to double-quoted JSON for strict
providers (e.g. Jackson).

Fixes json-path#1078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-quoted string arguments to path functions are dropped or corrupted; only double quotes work

1 participant