i'm having a problem with GSON, i'm trying to get a json file and transform them into a list of objects, i have no idea how to solve that, i tried to follow the article below but im recieving this error message below.
article: https://attacomsian.com/blog/gson-read-json-file
test.json
[
{
"code": "sasdsa321",
"items": [
{
"id":"1",
"name":"item1"
},
{
"id":"2",
"name":"item2"
},
...
]
},
...
]
my code
Gson gson = new Gson();
// create a reader
Reader reader = Files.newBufferedReader(Paths.get("test.json"));
// convert JSON array to list of items
List<Item> items= new Gson().fromJson(reader, new TypeToken<List<Item>>() {}.getType());
// print users
items.forEach(System.out::println);
Error message
"com.google.gson.stream.MalformedJsonException: Expected value at line 1 column 1 path $"