Reputation: 155
I am using Jackson library for serialising JSON,
having Serialising a Java Map, for ex, map<String,String>
has
{<color, green>,<color, blue>}
I want this to be serialised as
"colormap":[{"key": "color":, "value":"green"}, {"key": "color:, "value":"blue"}]
but its always serialising as
"colormap":[{"color":"green"}, {"color:"blue"}]
Upvotes: 0
Views: 50
Reputation: 194
Your output JSON is an array, not a map- Without looking at your code it's hard to tell what the underlying data structure is,but to do what you're looking for you might consider a class such as:
class Thing {
private String key ;
private String value ;
/// add accessors as needed
}
and then declare your colormap as List<Thing>
. This should seralize your data per your expectation.
Upvotes: 1