Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert the specific json api #192

Open
VW-LAMANDO opened this issue May 24, 2018 · 2 comments
Open

How to convert the specific json api #192

VW-LAMANDO opened this issue May 24, 2018 · 2 comments

Comments

@VW-LAMANDO
Copy link

Hi,

I met one issue, i need to request to webserver with JSON API.
request type shows below
{
"data":{
"type":"something"
}
}

I define the POJO.
after i define like below
@type("something")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Something {
@id
public String id;
}

the serialized string shows below:
{
"data": {
"type": "something",
"attributes": {}
}
}

how to disable the "attributes": {} ?
Wait your kindly reply. ^^

@peavers
Copy link
Contributor

peavers commented May 24, 2018

You can't as that would break the spec. See the docs for examples http://jsonapi.org/format/#document-top-level

@romanticjo
Copy link

romanticjo commented Jul 6, 2018

Sure you can:

http://jsonapi.org/format/#document-resource-objects

In addition, a resource object MAY contain any of these top-level members:

    attributes: an attributes object representing some of the resource’s data.
    relationships: a relationships object describing relationships between the resource and other JSON API resources.
    links: a links object containing links related to the resource.
    meta: a meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.

and

http://jsonapi.org/format/#crud-creating

A resource can be created by sending a POST request to a URL that represents a collection of resources. The request MUST include a single resource object as primary data. The resource object MUST contain at least a type member.

doesn't specify that an attributes must be present.

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

No branches or pull requests

3 participants