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 7544213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:37:23+00:00 2026-05-30T08:37:23+00:00

MyClass is as follows: @Getter class MyClass { private final DateTime start; private final

  • 0

MyClass is as follows:

@Getter
class MyClass
{
    private final DateTime start;
    private final DateTime end;
}

I want a List to serialize into JSON with Jackson but the format is not as expected. I’m currently digging the Jackson docs but they are a bit tricky for the first read.

The JSON output is now:

[ {
   "end" : "2012-02-16T13:59:59.000+01:00",
   "start" : "2012-02-16T13:35:42.000+01:00"
 }, {
   "end" : "2012-02-16T16:59:59.000+01:00",
   "start" : "2012-02-16T16:00:00.000+01:00"
 } ]

But I want it to be:

[ [ "2012-02-16T13:59:59.000+01:00", "2012-02-16T13:35:42.000+01:00"],
[ "2012-02-16T16:59:59.000+01:00", "2012-02-16T16:00:00.000+01:00" ] ]

So don’t print member names and replace inner {} with [].

  • 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-05-30T08:37:24+00:00Added an answer on May 30, 2026 at 8:37 am

    @JsonValue annotation is what you need: http://jackson.codehaus.org/1.0.1/javadoc/org/codehaus/jackson/annotate/JsonValue.html

    class MyClass {
        ...
        @JsonValue
        private DateTime[] toValue() {
            return new DateTime[] {start, end};
        }
    }
    

    This tells Jackson how MyClass should be treated while being serialized to JSON.

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

Sidebar

Related Questions

I have a class MyClass containing a private List<MySecondClass> myList . The list is
I have got a template class as follows: class MyClass<T> { T field; public
I have a __new__ method as follows: class MyClass(object): def __new__(cls, *args): new_args =
I have a class that inherits from a generic dictionary as follows: Class myClass
I have a ruby file as follows: module Example class Myclass def t_st Hello
I have a class with a delegate declaration as follows... Public Class MyClass Public
If a class is declared as follows: class MyClass { char * MyMember; MyClass()
My class is as follows public class CriteriaConfigImpl implements CriteriaConfig { private long elementId;
I have defined c:/temp/t.py as follows: class MyClass(object): def __init__(self): self._my_secret_thing = 1 def
I have 2 methods in C++ class as follows: class myClass { public: void

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.