micronaut-projects / micronaut-projects/micronaut-serialization
Switching to JSON-B Annotations & JSON-P breaks binding query parameters To POJO
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 36
- Forks
- 29
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 29
Description
Expected Behavior
Starting with this example project micronaut-jpa-hibernate-maven-java and switching from Jackson Annotations & Jackson Core to JSON-B Annotations & JSON-P in accordance with Micronaut Serialization a controller call that looks like this
@Get(value = "/list{?args*}")
List<Genre> list(@Valid SortingAndOrderArguments args) {
return genreRepository.findAll(args);
}
Should return a valid response when calling curl http://localhost:8080/genres/list?sort=name
Actual Behaviour
Instead, the following response is returned:
{"message":"Bad Request","_links":{"self":[{"href":"/genres/list?sort=name","templated":false}]},"_embedded":{"errors":[{"message":"Failed to convert argument [args] for value [null] due to: Cannot deserialize String sort due to: Not a string","path":"/args"}]}}
Steps To Reproduce
- Started with the Micronaut example application: micronaut-jpa-hibernate-maven-java
- Switched from Jackson Annotations & Jackson Core to JSON-B Annotations & JSON-P in accordance with Micronaut Serialization
- Making calls that use query parameters fail to deserialize:
curl http://localhost:8080/genres/list?sort=name
Using maven, this works:
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-runtime</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-jackson</artifactId>
<scope>compile</scope>
</dependency>
and this does not work:
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-runtime</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-jsonp</artifactId>
<version>1.5.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
Environment Information
OS: Microsoft Windows 10
JAVA: openjdk version "13.0.2" 2020-01-14
Example Application
https://github.com/ckapop/micronaut-jpa-hibernate-maven-java-jsonp-jsonb
Version
3.8.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked micronaut-jpa-hibernate-maven-java-jsonp-jsonb example application and reproduce the failure using the documented controller endpoint and curl request. Compare the Jackson and micronaut-serde-jsonp dependency setups, then trace query-parameter binding for SortingAndOrderArguments. Done means sort=name binds successfully and the genres list request returns a valid response under JSON-B/JSON-P.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100