I would recommend NOT using anything other than Jackson to process json.
A Jackson based solution for the JSON you have pasted would resemble this:-
First create a POJO for your book object
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class BookVO {
private final String isbn;
private final String title;
private final String[] author;
private final double price;
@JsonCreator
public BookVO(@JsonProperty("isbn") final String isbn, @JsonProperty("title") final String title, @JsonProperty("author") final String[] author, @JsonProperty("price") final double price) {
super();
this.isbn = isbn;
this.title = title;
this.author = author;
this.price = price;
}
public String getIsbn() {
return isbn;
}
public String getTitle() {
return title;
}
public String[] getAuthor() {
return author;
}
public double getPrice() {
return price;
}
}
You then need a Book container POJO
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Books {
private final BookVO book;
@JsonCreator
public Books(@JsonProperty("book") final BookVO book) {
super();
this.book = book;
}
public BookVO getBook() {
return book;
}
}
Finally you need to convert JSON to Java Objects as follows:-
public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
final ObjectMapper mapper = new ObjectMapper();
final Books books = mapper.readValue(new File("book.json"), Books.class);
System.out.println(books);
}
The content of book.json is
{
"book":{
"isbn" : "12356789",
"title" : "Algorithm",
"author" : [
"Cormen",
"Rivest",
"Stein"
],
"price" : 45.78
}
}