0
ObjectMapper mapper = new ObjectMapper();
List<String> stringIds = mapper.readValue(result, new TypeReference<List<String>>(){});

where result = { "stringids": [ "abc", "xyz" ] }

So for Input { "stringids": [ "abc", "xyz" ] }, I want the result to be a list of strings abc, xyz

Getting this exception when trying above code:- com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

Sahil
  • 75
  • 2
  • 9

1 Answers1

1

That's because you can't use a JSON library to deserialize broken JSON.

The correct way to represent a collection in JSON is ["abc", "def"] not {"abd", "def"}.

Nicktar
  • 5,548
  • 1
  • 28
  • 43