Object to Json conversion [duplicate]












0
















This question already has an answer here:




  • Best practice to Serialize java.time.LocalDateTime (java 8) to js Date using GSON

    2 answers



  • How to serialize and deserialize Java 8's java.time types with Gson? [closed]

    1 answer




I am converting my object to json.
Converted first my object to a Map.



It works fine fine for all the properties,except for except for properties of type "LocalDateTime".For "LocalDateTime" properties i am expecting value should be displayed in a single line like:
"UpdatedTimestamp": "2018-10-09T16:57:57.176",



But it displays like:



"UpdatedTimestamp": {
"dayOfYear": 326,
"dayOfWeek": "THURSDAY",
"month": "NOVEMBER",
"dayOfMonth": 22,
"year": 2018,
"monthValue": 11,
"hour": 1,
"minute": 14,
"second": 48,
"nano": 572000000,
"chronology": {
"id": "ISO",
"calendarType": "iso8601"
}
},


My current code:



Gson gson = new Gson();
String json = gson.toJson(object.getMap());









share|improve this question















marked as duplicate by shmosel java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 3:30


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • Best practice to Serialize java.time.LocalDateTime (java 8) to js Date using GSON

      2 answers



    • How to serialize and deserialize Java 8's java.time types with Gson? [closed]

      1 answer




    I am converting my object to json.
    Converted first my object to a Map.



    It works fine fine for all the properties,except for except for properties of type "LocalDateTime".For "LocalDateTime" properties i am expecting value should be displayed in a single line like:
    "UpdatedTimestamp": "2018-10-09T16:57:57.176",



    But it displays like:



    "UpdatedTimestamp": {
    "dayOfYear": 326,
    "dayOfWeek": "THURSDAY",
    "month": "NOVEMBER",
    "dayOfMonth": 22,
    "year": 2018,
    "monthValue": 11,
    "hour": 1,
    "minute": 14,
    "second": 48,
    "nano": 572000000,
    "chronology": {
    "id": "ISO",
    "calendarType": "iso8601"
    }
    },


    My current code:



    Gson gson = new Gson();
    String json = gson.toJson(object.getMap());









    share|improve this question















    marked as duplicate by shmosel java
    Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 22 '18 at 3:30


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • Best practice to Serialize java.time.LocalDateTime (java 8) to js Date using GSON

        2 answers



      • How to serialize and deserialize Java 8's java.time types with Gson? [closed]

        1 answer




      I am converting my object to json.
      Converted first my object to a Map.



      It works fine fine for all the properties,except for except for properties of type "LocalDateTime".For "LocalDateTime" properties i am expecting value should be displayed in a single line like:
      "UpdatedTimestamp": "2018-10-09T16:57:57.176",



      But it displays like:



      "UpdatedTimestamp": {
      "dayOfYear": 326,
      "dayOfWeek": "THURSDAY",
      "month": "NOVEMBER",
      "dayOfMonth": 22,
      "year": 2018,
      "monthValue": 11,
      "hour": 1,
      "minute": 14,
      "second": 48,
      "nano": 572000000,
      "chronology": {
      "id": "ISO",
      "calendarType": "iso8601"
      }
      },


      My current code:



      Gson gson = new Gson();
      String json = gson.toJson(object.getMap());









      share|improve this question

















      This question already has an answer here:




      • Best practice to Serialize java.time.LocalDateTime (java 8) to js Date using GSON

        2 answers



      • How to serialize and deserialize Java 8's java.time types with Gson? [closed]

        1 answer




      I am converting my object to json.
      Converted first my object to a Map.



      It works fine fine for all the properties,except for except for properties of type "LocalDateTime".For "LocalDateTime" properties i am expecting value should be displayed in a single line like:
      "UpdatedTimestamp": "2018-10-09T16:57:57.176",



      But it displays like:



      "UpdatedTimestamp": {
      "dayOfYear": 326,
      "dayOfWeek": "THURSDAY",
      "month": "NOVEMBER",
      "dayOfMonth": 22,
      "year": 2018,
      "monthValue": 11,
      "hour": 1,
      "minute": 14,
      "second": 48,
      "nano": 572000000,
      "chronology": {
      "id": "ISO",
      "calendarType": "iso8601"
      }
      },


      My current code:



      Gson gson = new Gson();
      String json = gson.toJson(object.getMap());




      This question already has an answer here:




      • Best practice to Serialize java.time.LocalDateTime (java 8) to js Date using GSON

        2 answers



      • How to serialize and deserialize Java 8's java.time types with Gson? [closed]

        1 answer








      java json rest file gson






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 3:29









      shmosel

      37k43996




      37k43996










      asked Nov 22 '18 at 3:28









      vasuvasu

      416




      416




      marked as duplicate by shmosel java
      Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 22 '18 at 3:30


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by shmosel java
      Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 22 '18 at 3:30


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          0






          active

          oldest

          votes

















          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents