You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Mike Barlotta (JIRA)" <ji...@apache.org> on 2019/03/01 22:25:00 UTC
[jira] [Commented] (CAMEL-11231) JSON Api Dataformat
[ https://issues.apache.org/jira/browse/CAMEL-11231?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16782166#comment-16782166 ]
Mike Barlotta commented on CAMEL-11231:
---------------------------------------
This is CodeSmell (from Gitter)
Quickly read through some of the documentation for JSON API
Assuming the basic goal is something like this
{code:java}
from("direct:start")
.marshal(jsonApi);
{code}
and
{code:java}
Item item = new Item("12345", "PINK PEEPS", "JUST BORN");
String jsonApiDoc = producer.requestBody("direct:start", item, String.class);{code}
and jsonApiDoc is something like this
{code:java}
{
"data": [
{
"id": "12345",
"type": "item",
"attributes": {
"description": "PINK PEEPS",
"supplierName": "JUST BORN"
}
}
]
}
{code}
Looking over each of the three projects listed.
Looks like each of them would require the POJO (in sample above the class Item) to have non-standard annotations
- [https://github.com/jasminb/jsonapi-converter]
{code:java}
import com.github.jasminb.jsonapi.annotations.Type;
import com.github.jasminb.jsonapi.annotations.Id;
@Type("item")
public class Item {
@Id
private String id;
...
{code}
or
- [https://github.com/crnk-project/crnk-framework]
{code:java}
import io.crnk.core.resource.annotations.JsonApiResource;
import io.crnk.core.resource.annotations.JsonApiId;
@JsonApiResource(type = "item")
public class Item {
@JsonApiId
private String id;
...{code}
or
- [https://github.com/faogustavo/JSONApi]
{code:java}
import com.gustavofao.jsonapi.Annotatios.Type;
import com.gustavofao.jsonapi.Models.Resource;
@Type("item")
public class Item extends Resource {
{code}
Of these I would not recommend [faogustavo/JSONApi|https://github.com/faogustavo/JSONApi] since that requires extending _Resource._ Would rather not force users of Camel to have to use a specific class hierarchy to use JSON API. I would need to look further at the other two libraries.
Ideally there would be a standardized set of annotations :)
> JSON Api Dataformat
> -------------------
>
> Key: CAMEL-11231
> URL: https://issues.apache.org/jira/browse/CAMEL-11231
> Project: Camel
> Issue Type: New Feature
> Reporter: Charles Moulliard
> Priority: Major
> Fix For: 3.0.0
>
>
> Implement a new DataFormat to support to serialize/deserialize JSONApi Objects/Strings as defined within the spec : [http://jsonapi.org/]
> Potential candidate projects to be evaluated :(
> - [https://github.com/jasminb/jsonapi-converter]
> - [https://github.com/faogustavo/JSONApi]
> - [https://github.com/crnk-project/crnk-framework]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)