-
-
Save seyedsahil/ae06a97a4832e9a2caa0eefe4890a014 to your computer and use it in GitHub Desktop.
Demo file created for json tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sydlabz.demo; | |
import com.google.gson.Gson; | |
import java.io.IOException; | |
import java.io.Reader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.LinkedHashMap; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class LoadData { | |
public static List<LinkedHashMap<?, ?>> load() throws IOException { | |
final String RESOURCE_PATH = "Absolute path of fruits.json"; | |
Gson gsonHandle = new Gson(); | |
Reader jsonReader = Files.newBufferedReader(Paths.get(RESOURCE_PATH)); | |
return new LinkedList<>(gsonHandle.fromJson(jsonReader, List.class)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment