0

I need to get the output something like this:

[
 {
   "index": 2,
   "range": true,
   "label": { 
              "Label1":"Value1",
              "Label2":"Value2"
            }
 }
]

combination of values with an integer boolean and map<string,string>

In Python we can do it simply with a list and a dictionary but how can I achieve this in Java?

4
  • 1
    what is the input type Commented Mar 27, 2021 at 17:16
  • so what holdes all these variables Commented Mar 27, 2021 at 17:16
  • 1
    Which question are you asking, how to create the lists and maps described, or how to convert them to JSON? Commented Mar 27, 2021 at 17:20
  • How to create lists and maps described Commented Mar 27, 2021 at 17:22

1 Answer 1

3

The structure you're describing appears to be something like this:

List.of(Map.of(
    "index", 2,
    "range", true,
    "label", Map.of("Label1", "Value1", "Label2", "Value2")
))

which is a List<Map<String, Object>>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.