Skip to content
Advertisement

Serialise Java Map as [{key: “key1, value: ”value1“}, {key: ”key2, value: “value2”}, …] [closed]

I’m going around in circles here because there’s about 50 questions on Stack Overflow asking how to get the default jackson behaviour… I don’t want that behaviour so don’t tell me this question has already been answered. Thanks.

I have a simple map HashMap<String, String> and need to serialise it into a form that a 3rd party app understands. I need the following:

JavaScript

I do NOT want this: {k1: "v1", k2: "v2", ...}

Anyone who understands the black art of jackson care to share their wisdom?

Advertisement

Answer

JavaScript

Output is:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement