Richard
Richard

Reputation: 8955

How do I know what implementation of jaxrs I am using?

I have a Java 1.7 starts application. It does have some RESTful api's.

I would like to add @JsonIgnore to a filed so that it is not returned in the api.

E.g.

Member.java

import com.fasterxml.jackson.annotation.JsonIgnore;
    
private java.lang.String username;
@JsonIgnore
private java.lang.String password;

Does not ignore the password.

"member": {
    "password": "**************",
    "username": "richard"
}

I think the reason why @JsonIgnore does not work, is because I use com.fasterxml.jackson.annotation.JsonIgnore. Should I use a different annotation from a different library? i.e. Is my implementation of jaxrs maybe not com.fasterxml.jackson? How do I tell?

The IntelliJ classpath has:

enter image description here

(I have tried net.minidev.json.annotate.JsonIgnore with no success)

More info:

pom.xml

<dependency>
    <groupId>net.minidev</groupId>
    <artifactId>json-smart</artifactId>
    <version>2.3</version>
</dependency>

and

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.2</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.11.2</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.11.2</version>
</dependency>

enter image description here

Is this the problem? two versions! I am not sure where the 2.0.5 version comes from, as it is not defined in the pom.

enter image description here

Upvotes: 0

Views: 254

Answers (1)

Daniel Jacob
Daniel Jacob

Reputation: 1546

You don't need a @JsonIgnore in this case. You can simply omit the variable that you don't want deserialized(the password in this case) and jackson will just return you the username.

Upvotes: 1

Related Questions