GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — timestamp (de)serialization not work on msgpack-jackson 0.9.3 · Issue #674 · msgpack/msgpack-java

timestamp (de)serialization not work on msgpack-jackson 0.9.3 #674

New issue
Copy link
New issue
Copy link
Closed
#677
Closed
timestamp (de)serialization not work on msgpack-jackson 0.9.3#674
#677
Copy link
Assignees
komamitsu

Description

@changwoo
changwoo
opened on Sep 2, 2022
Issue body actions

I saw the news of timestamp extension support on version 0.9.0 and tried it. But I still can't (de)serialize timestamps with the 0.9.3 version. Is it supported also when using Jackson?

I did like this and the "Instant" was serialized as a map of string keys "epochSecond"/"nano" and uint32 values.

private static class A {
    @JsonProperty(index = 0)
    Instant instant = Instant.now();
}

....

    A a = new A();
    ObjectMapper objectMapper = new MessagePackMapper();
    byte[] bytes = objectMapper.writeValueAsBytes(a);

Activity

  1. komamitsu
    self-assigned this
    on Sep 8, 2022
  2. komamitsu commented on Sep 9, 2022

    @komamitsu
    komamitsu
    on Sep 9, 2022
    Member
    More actions

    Yes. I don't think Jackson can handle private classes.

    public class Pojo {
        public int i = 42;
        public Instant now = Instant.now();
    }
    
      :
    
        ObjectMapper mapper = new ObjectMapper(new MessagePackFactory());
        Pojo x = new Pojo();
        byte[] bytes = mapper.writeValueAsBytes(x);
        System.out.println(mapper.readValue(bytes, new TypeReference<Map<String, Object>>() {}));
            >>>> {i=42, now={epochSecond=1662712326, nano=653000000}}
  3. komamitsu
    closed this as completedon Sep 9, 2022
  4. changwoo commented on Sep 11, 2022

    @changwoo
    changwoo
    on Sep 11, 2022
    Author
    More actions

    Yes. I don't think Jackson can handle private classes.

    public class Pojo {
        public int i = 42;
        public Instant now = Instant.now();
    }
    
      :
    
        ObjectMapper mapper = new ObjectMapper(new MessagePackFactory());
        Pojo x = new Pojo();
        byte[] bytes = mapper.writeValueAsBytes(x);
        System.out.println(mapper.readValue(bytes, new TypeReference<Map<String, Object>>() {}));
            >>>> {i=42, now={epochSecond=1662712326, nano=653000000}}

    Jackson CAN handle private classes.

    I mean, the timestamps were not serialized in the extension format.

    Your example Pojo class was serialized like this:

    // 82 a1 69 2a a3 6e 6f 77 82 ab 65 70 6f 63 68 53 65 63 6f 6e 64 ce 63 1d 90 50 a4 6e 61 6e 6f ce 05 8b 11 40 
    //       i  42    n  o  w        e  p  o  c  h  S  e  c  o  n  d                    n  a  n  o
    

    This is not the timestamp extension format. It's just a map with string keys and uint32 values.

  5. komamitsu commented on Sep 11, 2022

    @komamitsu
    komamitsu
    on Sep 11, 2022
    Member
    More actions

    Oops. Sorry, I misread your comment the other way around.

    Supporting only Instant shouldn't be difficult. But someone may want to use java.time.LocalDateTime or other classes. Let me think about it...

  6. komamitsu
    reopened this on Sep 11, 2022
  7. komamitsu
    closed this as completedin #677on Sep 14, 2022
  8. komamitsu commented on Sep 14, 2022

    @komamitsu
    komamitsu
    on Sep 14, 2022
    Member
    More actions

    We decided to simply support only Instant. With the feature introduced by #677, Instant instances will be serialized and deserialized automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @komamitsu
    komamitsu

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.