-
-
Save TheSithPadawan/f10264f2279947cfe9fbe7af6105f59a to your computer and use it in GitHub Desktop.
Read json from file into Gson
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
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import com.google.gson.Gson; | |
public class GsonTest { | |
public static void main(String[] args) throws FileNotFoundException { | |
String path = "PATH TO YOUR JSON FILE"; | |
BufferedReader bufferedReader = new BufferedReader(new FileReader(path)); | |
Gson gson = new Gson(); | |
Object json = gson.fromJson(bufferedReader, Object.class); | |
System.out.println(json.getClass()); | |
System.out.println(json.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment