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

vavr serialization can ignore field? #119

Open
BornToRain opened this issue Nov 24, 2017 · 5 comments
Open

vavr serialization can ignore field? #119

BornToRain opened this issue Nov 24, 2017 · 5 comments
Labels

Comments

@BornToRain
Copy link

vavr serialization

    "items": {
      "async": false,
      "ordered": false,
      "traversableAgain": true,
      "lazy": false,
      "sequential": false,
      "distinct": true,
      "memoized": false,
      "singleValued": false,
      "empty": true,
      "orNull": null,
      "id": "451565338509840384"
    }

I want serialization

"items": {
      "id": "451565338509840384"
     }
@ruslansennov
Copy link
Member

what object are you serializing? can you provide a reproducer?

@BornToRain
Copy link
Author

io.vavr.collection.HashMap

@ruslansennov
Copy link
Member

you should register the VavrModule in the ObjectMapper

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vavr.collection.HashMap;
import io.vavr.jackson.datatype.VavrModule;
import org.junit.Test;

public class Iss119 {

    private final HashMap<String, String> items = HashMap.of("id", "451565338509840384");

    @Test
    public void unregistered() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        System.out.println(mapper.writeValueAsString(items));
        // {"async":false,"lazy":false,"empty":false,"traversableAgain":true ...
    }

    @Test
    public void registered() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper()
                .registerModule(new VavrModule());  //  <-- register Vavr Jackson Module
        System.out.println(mapper.writeValueAsString(items));
        // {"id":"451565338509840384"}
    }
}

@BornToRain
Copy link
Author

thanks, vavr collection is ok.but Future have problem.
image
controller return io.vavr.concurrent.Future have error;
image
Future.toCompletableFuture() is ok;

@ruslansennov
Copy link
Member

VavrModule does not process serialization/deserialization of Future and Try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants