I have a json object that has nested objects, like this:
{
"process": "create",
"processDescription": "some description",
"book": {
"id": "some unique id",
"bookName": "some name",
"bookISBN": "some number",
"bookDesc": "some description",
"author": {
"id": "a different ID",
"firstName": "some name",
"lastName": "some description"
},
"timestampUpdated": null,
"timestampCreated": 1672753599223,
"createdByUser": "Jane Doe",
"updatedByUser": null
},
"someField": "some data",
"anotherField": "more data"
}
In this example, I am only concerned with the "book" object and the "author" object. So, I have Java Classes for both of them. I've tried to read in the json string like this:
JsonNode jsonObject = new ObjectMapper().readTree(jsonString);
JsonNode bookObj = jsonObject.get("book");
JsonNode authorObj = bookObj.get("author");
ObjectMapper objectMapper = new ObjectMapper();
AuthorClass = objectMapper.readValue(authorObj.asText(), AuthorClass .class);
but this causes an error:
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input at [Source: (String)""; line: 1, column: 0]