Package eliasstar.json
Class Json
- java.lang.Object
-
- eliasstar.json.Json
-
public class Json extends Object
Provides a simple toJson and fromJson method.- Since:
- 1.0.0
- Author:
- Elias*
-
-
Constructor Summary
Constructors Constructor Description Json()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
fromJson(String json)
Parses a JSON string into a Java object treestatic Object
readFile(String path)
static String
toJson(Object object)
Converts an object to a JSON string.static void
writeFile(String path, Object object)
-
-
-
Method Detail
-
writeFile
public static void writeFile(String path, Object object) throws IOException, JsonException
- Throws:
IOException
JsonException
-
readFile
public static Object readFile(String path) throws IOException, JsonException
- Throws:
IOException
JsonException
-
toJson
public static String toJson(Object object) throws JsonException
Converts an object to a JSON string.- Parameters:
object
- The object in question- Returns:
- A JSON encoded string
- Throws:
JsonException
-
fromJson
public static Object fromJson(String json) throws StateMachineException, EmptyJsonException, MalformedJsonException, InvalidJsonTypeException, JsonNumberFormatException
Parses a JSON string into a Java object tree- Parameters:
json
- The JSON string to be parsed- Returns:
- An object representing the json tree
- Throws:
StateMachineException
EmptyJsonException
MalformedJsonException
InvalidJsonTypeException
JsonNumberFormatException
-
-