What version of OpenRewrite are you using?
- OpenRewrite v8.64.0
- Maven/Gradle plugin v6.22.1
Description
Running the AddKeyValue recipe for a valid JSON file prints parser error:
line 1:2 mismatched input '<EOF>' expecting {'[', '*', Identifier, StringLiteral}
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.22.1</version>
<configuration>
...
</configuration>
</plugin>
What is the smallest, simplest way to reproduce the problem?
rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: sampleJsonAddKey
displayName: JSON Sample
recipeList:
- org.openrewrite.json.AddKeyValue:
keyPath: "$."
key: "surname"
value: "\"Doe\""
When running the above recipe using mvn rewrite:run against the following json:
the key surname is correctly added to the JSON with the intended value but parsing errors are printed
[INFO] Running recipe(s)...
line 1:2 mismatched input '<EOF>' expecting {'[', '*', Identifier, StringLiteral}
[WARNING] Changes have been made to pre.json by:
[WARNING] org.openrewrite.json.AddKeyValue: {keyPath=$., key=surname, value="Doe", prepend=false}
[WARNING] Please review and commit the results.
[WARNING] Estimate time saved: 5m
Even when filtering to only valid JSON files using FindSourceFiles the parser error stills prints
---
type: specs.openrewrite.org/v1beta/recipe
name: sampleJsonAddKey
displayName: JSON Sample
preconditions:
- org.openrewrite.FindSourceFiles:
filePattern: "**/*.json"
recipeList:
- org.openrewrite.json.AddKeyValue:
keyPath: "$."
key: "surname"
value: "\"Doe\""
What did you expect to see?
No parsing errors for valid JSON files
What did you see instead?
Parsing errors printed for valid JSON files
What version of OpenRewrite are you using?
Description
Running the AddKeyValue recipe for a valid JSON file prints parser error:
line 1:2 mismatched input '<EOF>' expecting {'[', '*', Identifier, StringLiteral}How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
rewrite.yml
When running the above recipe using
mvn rewrite:runagainst the following json:{ "name": "John" }the key
surnameis correctly added to the JSON with the intended value but parsing errors are printedEven when filtering to only valid JSON files using
FindSourceFilesthe parser error stills printsWhat did you expect to see?
No parsing errors for valid JSON files
What did you see instead?
Parsing errors printed for valid JSON files