Skip to content
This repository was archived by the owner on Nov 27, 2021. It is now read-only.
This repository was archived by the owner on Nov 27, 2021. It is now read-only.

Fails to Deserialize  #6

@ghost

Description

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at xyz.matthewtgm.json.serialization.JsonDeserializer.createClassInstance(JsonDeserializer.java:68)
	at xyz.matthewtgm.json.serialization.JsonDeserializer.deserialize(JsonDeserializer.java:31)
	at dev.fxe.TGMJsonBenchmark.deserialize(TGMJsonBenchmark.java:19)
	at dev.fxe.DataGenerator.main(DataGenerator.java:39)
public static void deserialize() throws FileNotFoundException {
	BufferedReader bufferedReader = new BufferedReader(new FileReader("people.json"));
	String data = bufferedReader.lines().collect(Collectors.joining());
	Person[] people = JsonDeserializer.deserialize(data, Person[].class);
}


public class Person {

	String fullName;
	String firstName;
	String lastName;
	String address;
	int age;
	Book favouriteBook;

	public Person(String fullName, String firstName, String lastName, String address, int age, String author, String title) {
		this.fullName = fullName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.address = address;
		this.age = age;
		this.favouriteBook = new Book(author, title);
	}
}

public class Book {

	String author;
	String title;

	public Book(String author, String tittle) {
		this.author = author;
		this.title = tittle;
	}
}

The file to deserialize

people.json

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions