Package com.syntifi.near.api.json
Class JsonHelper
- java.lang.Object
-
- com.syntifi.near.api.json.JsonHelper
-
public final class JsonHelper extends java.lang.Object
Basic support functionality for test case classes- Since:
- 0.0.1
- Author:
- Alexandre Carvalho, Andre Bertolace
-
-
Field Summary
Fields Modifier and Type Field Description static com.fasterxml.jackson.databind.ObjectMapper
OBJECT_MAPPER
-
Constructor Summary
Constructors Constructor Description JsonHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getPrettyJson(java.lang.Object jsonObject)
Prettifies json for assertion consistencystatic java.lang.String
getPrettyJson(java.lang.String json)
Prettifies json for assertion consistencystatic java.lang.String
loadJsonFromFile(java.io.File file)
Loads test json from resourcesstatic java.lang.String
loadJsonFromResourceFile(java.lang.String filename)
Loads test json from resources
-
-
-
Method Detail
-
loadJsonFromFile
public static java.lang.String loadJsonFromFile(java.io.File file) throws java.io.IOException
Loads test json from resources- Parameters:
file
- file to load from- Returns:
- file content
- Throws:
java.io.IOException
- thrown if error reading file
-
loadJsonFromResourceFile
public static java.lang.String loadJsonFromResourceFile(java.lang.String filename) throws java.io.IOException
Loads test json from resources- Parameters:
filename
- filename to load- Returns:
- file content
- Throws:
java.io.IOException
- thrown if error reading file
-
getPrettyJson
public static java.lang.String getPrettyJson(java.lang.String json) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException
Prettifies json for assertion consistency- Parameters:
json
- json string to prettify- Returns:
- prettified json
- Throws:
com.fasterxml.jackson.databind.JsonMappingException
- thrown if error mapping jsoncom.fasterxml.jackson.core.JsonProcessingException
- thrown if error processing json
-
getPrettyJson
public static java.lang.String getPrettyJson(java.lang.Object jsonObject) throws com.fasterxml.jackson.core.JsonProcessingException
Prettifies json for assertion consistency- Parameters:
jsonObject
- object to serialize and prettify- Returns:
- prettified json
- Throws:
com.fasterxml.jackson.databind.JsonMappingException
- thrown if error mapping jsoncom.fasterxml.jackson.core.JsonProcessingException
- thrown if error processing json
-
-