-1

Finding issues in reading the json string using object mapper read value method. Can be able to retrieve the individual fields but unable to read array values as mentioned below.

{
  "Stuname":"Test",
  "State":"CREATE",
  "resourceIds": ["{stuId: 814981025958, branches:[10, 4946]}"]
}

using

objectMapper.readValue(message, StudentState.class);

In which stuname,state and resourceids collection as well as array also tried. but not able to read it. For resourceids created seperate class which hold stuId and array of locations.

Student State Class :

public class StudentState{
    private String Stuname;
    private String state;
    private Resources []  resourceIds;
    //private Collection<Resources> resourceIds;
    //Added respective getter/ setter
}
tobsob
  • 602
  • 9
  • 22
Java Learner
  • 87
  • 1
  • 2
  • 8

1 Answers1

0

Your json array values don't look like valid, it looks like an array with embedded json. Probably it should look like this:

{
  "Stuname": "Test",
  "State": "CREATE",
  "resourceIds": [
    {
      "stuId": 814981025958, "branches": [10, 4946]
    }
  ]
}
MariuszS
  • 30,646
  • 12
  • 114
  • 155