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 — Better Deserialization of Extension Types with Jackson · Issue #398 · msgpack/msgpack-java

Better Deserialization of Extension Types with Jackson #398

New issue
Copy link
New issue
Copy link
Closed
Closed
Better Deserialization of Extension Types with Jackson#398
Copy link
Assignees
komamitsu

Description

@fuyumatsuri
fuyumatsuri
opened on Oct 22, 2016
Issue body actions

If you do a readTree that contains an extension type, the resulting tree will look something like (for example) [1, 2, [MessagePackExtensionType, MessagePackExtensionType']. In order to make this tree usable you need to traverse the whole tree converting any MessagePackExtensionType object to the real object type. It would be much better if reading the tree instead resulted in [1, 2, [RealClass, RealClass]].

Ideally I would like to be able to do something along the lines of

factory = new MessagePackFactory
factory.register(typeId, class, encoder, decoder)

and have MessagePackParser check if a type is registered to return the correct object.

Activity

  1. clarkdo commented on Dec 29, 2016

    @clarkdo
    clarkdo
    on Dec 29, 2016
    More actions

    +1

  2. komamitsu
    self-assigned this
    on Jan 3, 2017
  3. komamitsu commented on Jan 19, 2017

    @komamitsu
    komamitsu
    on Jan 19, 2017
    Member
    More actions

    @Chad- @clarkdo Does this feature satisfy your request? https://github.com/msgpack/msgpack-java/pull/408/files#diff-da72e095f423bf63a2b05b8196b564dfR720

        ExtensionTypeCustomDeserializers extTypeCustomDesers = new ExtensionTypeCustomDeserializers();
        extTypeCustomDesers.addTargetClass((byte) 17, NestedListComplexPojo.class);
        extTypeCustomDesers.addTargetTypeReference((byte) 99, new TypeReference<Map<String, Integer>>() {});
        extTypeCustomDesers.addCustomDeser((byte) 31, new ExtensionTypeCustomDeserializers.Deser() {
                    @Override
                    public Object deserialize(byte[] data)
                            throws IOException
                    {
                        if (Arrays.equals(data, new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE})) {
                            return "Java";
                        }
                        return "Not Java";
                    }
                }
        );
        ObjectMapper objectMapper =
                new ObjectMapper(new MessagePackFactory().setExtTypeCustomDesers(extTypeCustomDesers));
    
    Reacted by Xin Du (Clark)
  4. komamitsu commented on Jan 25, 2017

    @komamitsu
    komamitsu
    on Jan 25, 2017
    Member
    More actions

    Merged the above feature. I hope it solves this request.

  5. komamitsu
    closed this as completedon Jan 25, 2017
  6. clarkdo commented on Jan 25, 2017

    @clarkdo
    clarkdo
    on Jan 25, 2017
    More actions

    @komamitsu thanks. It should be helpful.

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.