parser json to java
This commit is contained in:
parent
fbd690f427
commit
f2b2fa9e9b
23
src/configuration/JsonToJava.java
Normal file
23
src/configuration/JsonToJava.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package configuration;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
public class JsonToJava {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
JSONParser jsonP = new JSONParser();
|
||||||
|
try {
|
||||||
|
JSONObject jsonO = (JSONObject)jsonP.parse(new FileReader("src/configuration/config.json"));
|
||||||
|
|
||||||
|
String test = (String) jsonO.get("test");
|
||||||
|
System.out.println("Name :"+ test);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user