Package org.kissweb
Class JsonTemplate
java.lang.Object
org.kissweb.JsonTemplate
This class replaces occurrences of ${NAME} with values obtained from a supplied map.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.json.JSONObjectFill all occurrences of variables in the form ${VAR} with the values given in the map.static org.json.JSONObjectFill all occurrences of variables in the form ${VAR} with the values given in the map.static void
-
Constructor Details
-
JsonTemplate
public JsonTemplate()
-
-
Method Details
-
fill
Fill all occurrences of variables in the form ${VAR} with the values given in the map.
Ifjstris a file name, the json will be taken from the file.- Parameters:
jstr- the json string or file namemap- a map mapping variable name to replacement text.- Returns:
- Throws:
IOException- See Also:
-
fill
public static org.json.JSONObject fill(org.json.JSONObject jobj, Map<String, String> map) throws IOExceptionFill all occurrences of variables in the form ${VAR} with the values given in the map.
Ifjstris a file name, the json will be taken from the file.- Parameters:
jobj- the json objectmap- a map mapping variable name to replacement text.- Returns:
- Throws:
IOException- See Also:
-
main
- Throws:
IOException
-