diff --git a/pom.xml b/pom.xml
index 09ce924d..0be33f00 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,6 +20,11 @@
4.12
test
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
diff --git a/src/main/java/seng302/FileParser.java b/src/main/java/seng302/FileParser.java
new file mode 100644
index 00000000..2fe26d0f
--- /dev/null
+++ b/src/main/java/seng302/FileParser.java
@@ -0,0 +1,92 @@
+package seng302;
+
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+
+
+/**
+ * Read team name from a given Json file. So that user can extract information
+ * efficiently from external files.
+ */
+
+public class FileParser {
+
+ private String filePath;
+ private JSONObject content;
+ /** used to construct an instance of file parser
+ *
+ * @param filePath a string like path to show location of desired file to
+ * be parsed
+ */
+ public FileParser(String filePath) throws Exception {
+ this.filePath = filePath;
+ this.readFile();
+ }
+
+ /**
+ * Reads content from a given file, and return the content as JSONObject.
+ * Throws FileNotFoundException, if the given file cannot be found.
+ */
+ private void readFile() throws FileNotFoundException{
+ JSONParser parser = new JSONParser();
+ try {
+ Object obj = parser.parse(new FileReader(filePath));
+
+ JSONObject jsonObject = (JSONObject) obj;
+ this.content = jsonObject;
+ } catch (FileNotFoundException e) {
+ throw e;
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Gets time scale setting parameter.
+ * @return long time scale. -1 if parameter is invalid (eg. scale is
+ * negative number, or containing non numeric character) or cannot be found.
+ */
+ public long getTimeScale() {
+ try {
+ long timeScale = (long) this.content.get("time-scale");
+ return timeScale >= 0 ? timeScale : -1;
+ } catch (Exception e) {
+ return -1;
+ }
+ }
+
+ /**
+ * Gets race name in the setting file.
+ * @return a string of race name. null if race name is invalid or cannot
+ * be found.
+ */
+ public String getRaceName() {
+ try {
+ return (String) this.content.get("race-name");
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Gets an array of teams who participate the race.
+ * @return an ArrayList containing strings of team names. null if teams
+ * setting is invalid or there is no team.
+ */
+ public ArrayList getTeams() {
+ try {
+ return (ArrayList) this.content.get("teams");
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/seng302/FileParserTest.java b/src/test/java/seng302/FileParserTest.java
new file mode 100644
index 00000000..05c71a9e
--- /dev/null
+++ b/src/test/java/seng302/FileParserTest.java
@@ -0,0 +1,53 @@
+package seng302;
+
+import org.junit.Test;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+/** Unit test for FileParser class
+ * Created by Haoming on 5/03/17.
+ */
+public class FileParserTest {
+
+ /*
+ test if it fails from reading non existed file
+ */
+ @Test (expected = FileNotFoundException.class)
+ public void readNonExistedFile() throws Exception {
+ FileParser fileParser = new FileParser("test/java/seng302/non-existed.json");
+ }
+
+ /*
+ test a valid json file with valid content.
+ */
+ @Test
+ public void readValidFile() throws Exception{
+ FileParser fileParser = new FileParser("src/test/java/seng302/valid.json");
+
+ assertEquals(fileParser.getRaceName(), "IDK");
+
+ ArrayList teams = new ArrayList<>();
+ teams.add("team1");
+ teams.add("team2");
+ teams.add("team3");
+ assertTrue(teams.equals(fileParser.getTeams()));
+ }
+
+ /*
+ test an invalid json file within wrong type value and misnamed
+ variable name.
+ */
+ @Test
+ public void readInvaldFile() throws Exception {
+ FileParser fileParser = new FileParser("src/test/java/seng302/invalid.json");
+
+ assertEquals(fileParser.getRaceName(), null);
+ assertEquals(fileParser.getTeams(), null);
+ assertEquals(fileParser.getTimeScale(), -1);
+ assertEquals(fileParser.getTeams(), null);
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/seng302/invalid.json b/src/test/java/seng302/invalid.json
new file mode 100644
index 00000000..43331785
--- /dev/null
+++ b/src/test/java/seng302/invalid.json
@@ -0,0 +1,5 @@
+{
+ "time-scale": "abc",
+ "race-name": 123,
+ "teams-with-wrong-name":["team1","team2","team3"]
+}
\ No newline at end of file
diff --git a/src/test/java/seng302/valid.json b/src/test/java/seng302/valid.json
new file mode 100644
index 00000000..21b0c2dc
--- /dev/null
+++ b/src/test/java/seng302/valid.json
@@ -0,0 +1,5 @@
+{
+ "time-scale": 100,
+ "race-name": "IDK",
+ "teams":["team1","team2","team3"]
+}
\ No newline at end of file