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

  • SEARCH
  • Home
  • 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 8450505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:59:10+00:00 2026-06-10T10:59:10+00:00

There’s a project use Jackson, and have a Java object Data. In the object,

  • 0

There’s a project use Jackson, and have a Java object Data. In the object, there’s a property, and it’s also a object Raw. In this object,there’s a property List<Object[]>
e.g:

public class Data{
    Raw raw;
}

public class Raw{
    List<Object[]> list;
}

If the Object[] have a data type: long, and I give a value: 123, then the Jackson will convert this data type to int,

i.e: If the value’s length < long && > int , the data type is also long, if length < int, the data type will become int.

I use the method:

 byte[] bytes = writeValueAsBytes(Data), Data data = readValue(bytes, Data.class)

How could I keep the original data type when it is converted?

  • 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-10T10:59:11+00:00Added an answer on June 10, 2026 at 10:59 am

    Jackson does what I think you want:

    @Test
    public void testJackson() throws Exception {
        List<Number> numbers = new ArrayList<Number>();
        numbers.add(100L);
        numbers.add(new Long(Integer.MAX_VALUE) + 1000L);
        numbers.add(10.0);
        ObjectMapper om = new ObjectMapper();
        System.out.println(om.writeValueAsString(numbers));
        List<Number> newNumbers = om.readValue(om.writeValueAsString(numbers), ArrayList.class);
        System.out.println(newNumbers);
        assertEquals(Integer.class, newNumbers.get(0).getClass());
        assertEquals(newNumbers.get(1).getClass(), Long.class);
        assertTrue(! numbers.equals(newNumbers) );
    }
    

    However numbers will not equal newNumbers because 100L should be an integer.
    The maximum number that JSON can handle is a 64 bit double precision.

    If your doing data serialization like for binary images then I would encode the data in Base64.

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

Sidebar

Related Questions

There is this strange situation I'm fighting on. I have 3 pages, les call
There have been multiple questions regarding this topic but I have never really settled
There's a sample ASP.NET project with this controller: using System; using System.Collections.Generic; using System.Web;
(There's a lot of similar questions on this, and I've also read through various
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There are nice SO question and answers about this issue, but these options didn't
There will be 500+ threads concurrently uploading an unique object to a bucket all
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
There must be a simple solution to this, but after 4 hours of browsing

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.