Summary
Move JSON serialization from AppleScript string concatenation to the Swift layer to handle special characters robustly.
Details
Currently, AppleScript templates build JSON output via string concatenation, which is fragile when values contain:
- Quotes (
")
- Backslashes (
\)
- Newlines (
\n)
- Other special characters
The fix is to move JSON serialization into the Swift executor layer (e.g., using JSONSerialization or Codable), where proper escaping is handled natively.
Affected files
packages/executor-swift/Sources/Executor/*Templates.swift (10 app template files)
- Possibly
packages/executor-swift/Sources/Executor/JsonIO.swift
From TODO.md
Harden AppleScript JSON output — Move JSON serialization from AppleScript string concatenation to the Swift layer to handle special characters (quotes, backslashes, newlines) robustly
Summary
Move JSON serialization from AppleScript string concatenation to the Swift layer to handle special characters robustly.
Details
Currently, AppleScript templates build JSON output via string concatenation, which is fragile when values contain:
")\)\n)The fix is to move JSON serialization into the Swift executor layer (e.g., using
JSONSerializationorCodable), where proper escaping is handled natively.Affected files
packages/executor-swift/Sources/Executor/*Templates.swift(10 app template files)packages/executor-swift/Sources/Executor/JsonIO.swiftFrom TODO.md
Harden AppleScript JSON output — Move JSON serialization from AppleScript string concatenation to the Swift layer to handle special characters (quotes, backslashes, newlines) robustly