Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:05:36+00:00 2026-06-13T07:05:36+00:00

use messagepack on android, the can serialize/deserialize a class, but not absolutely right .

  • 0

use messagepack on android, the can serialize/deserialize a class, but not absolutely right
.

the simple test class:

    @Message
public class Account {

    public String Code;
    public int Sequence;
    public float Lot;

    public String toString(){
        return "Seq:"+Sequence;
    }
}

The test code :

MessagePack msgpack = new MessagePack();
    msgpack.register(Account.class);
    try {
    Account a = new Account();
    a.Code ="name";
    a.Sequence = 105;
    a.Lot = (float)1.05;
    byte[] b = msgpack.write(a);
    //byte[] c = MessagePack.pack(a);
    Account aa = msgpack.read(b, Account.class );
    System.out.println(new String(b));
    System.out.println("test00: aa.Lot "+aa.Lot);
    }catch(IOException e){
        e.printStackTrace();
    }

after run “byte[] b = msgpack.write(a);” on android the output byte array b[] is incorrect (compare to java)

[-109, -92, 110, 97, 109, 101, 105, -54, 63, -122, 102, 102]   on java

[-109, -92, 110, 97, 109, 101, -54, 63, -122, 102, 102, 105]   on android

I have review Using MessagePack with Android

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:05:37+00:00Added an answer on June 13, 2026 at 7:05 am

    MessagePack is not, intrinsically, an object serializer. It is meant to serialize well-defined data structures. In Java there is no notion of order between the fields of an object. These MessagePack implementations probably introduce one so that they can serialize and deserialize objects but it is not guaranteed that it will be the same on different machines.

    If you unpack your byte arrays, here is what they actually contain:

    ["name", 105, 1.05] on Java
    ["name", 1.05, 105] on Android
    

    If you want to serialize an object in a portable way, write a specific serialization method with a well-defined order for members, or use a map type, which corresponds more closely to an object.

    Note that this is a reported bug here: http://jira.msgpack.org/browse/MSGPACK-51

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use level1\level2\level3; Can someone explain with a simple demo ?
Has someone tried to use MessagePack with an Android app? Is it possible? I
I'm trying to use MessagePack in a WAR application in Glassfish, but I'm getting
use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;
use Data::Dumper; %hash = ( Key => {test => [[testvalue, 10], [testvalue, 20]]}, Key2
use strict; my $var = NULL; will raise an error of Bareword NULL not
USE AdventureWorks; GO IF OBJECT_ID (N'dbo.AWBuildVersion', N'U') IS NOT NULL DROP TABLE dbo.AWBuildVersion; GO
use warnings; use Test::More; use File::Find::Rule; use Test::File::Find::Rule; my $rule = File::Find::Rule->file->name('*.pl')->not_grep(qr/^\s*use\s+strict;/m, sub {
Use scenario is pretty simple: I have a desktop only application that could be
Use case: I find a piece of code that I do not understand at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.