JsonSerializer and JSON output fields order

7 views
Skip to first unread message

David Marko

unread,
Nov 20, 2015, 5:53:13 AM11/20/15
to Jodders
Is there a way how  to instruct JsonSerializer to output fields in order as defined in java bean? Currenty it creates alphabetical order. Sometimes the field order logic is important for output e.g. 'id' is first etc. 

Example output as created today:
{
   
"attachments":[],
   
"company":{
     
"address":"",
     
"city":"",
     
"country":"",
     
"description":"",
     
"id":"",
     
"name":"",
     
"zip":""
   
},
   
"externalId":"",
   
"from":null,
   
"id":"662A0EECD2008282C1257DEF003E0F00",
   
"language":""
 
},


David Marko

unread,
Nov 20, 2015, 7:44:13 AM11/20/15
to Jodders
I just found out that converting LinkedHashMap object (instead of java bean) to JSON maintains the key names in proper order ... great!

Dne pátek 20. listopadu 2015 11:53:13 UTC+1 David Marko napsal(a):
Reply all
Reply to author
Forward
0 new messages