Package org.kissweb

Class JsonTemplate

java.lang.Object
org.kissweb.JsonTemplate

public class JsonTemplate extends Object
This class replaces occurrences of ${NAME} with values obtained from a supplied map.
  • Constructor Details

    • JsonTemplate

      public JsonTemplate()
  • Method Details

    • fill

      public static org.json.JSONObject fill(String jstr, Map<String,String> map) throws IOException
      Fill all occurrences of variables in the form ${VAR} with the values given in the map.

      If jstr is a file name, the json will be taken from the file.
      Parameters:
      jstr - the json string or file name
      map - 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 IOException
      Fill all occurrences of variables in the form ${VAR} with the values given in the map.

      If jstr is a file name, the json will be taken from the file.
      Parameters:
      jobj - the json object
      map - a map mapping variable name to replacement text.
      Returns:
      Throws:
      IOException
      See Also:
    • main

      public static void main(String[] argv) throws IOException
      Throws:
      IOException