Class JsonTemplate


public class JsonTemplate extends JsonFragment
Describes the JSON a JsonWriter produces: nodes before the JsonFragment.detail() marker form the header, the marker's nodes are written once per record and the remaining nodes form the footer.
  • Constructor Details

    • JsonTemplate

      public JsonTemplate()
  • Method Details

    • setValue

      public void setValue(String name, Object value)
      Sets a named value that the template's expressions, including per-record ones, can reference.
    • setValue

      public void setValue(String name, Object value, Class<?> type)
      Sets a named value of the given type that the template's expressions, including per-record ones, can reference.
    • buildHeader

      public void buildHeader(com.fasterxml.jackson.core.JsonGenerator jsonGenerator) throws IOException
      Writes the nodes that come before the detail marker; call it once before writing records.
      Throws:
      IOException
    • buildDetail

      public void buildDetail(Record record, com.fasterxml.jackson.core.JsonGenerator jsonGenerator) throws IOException
      Writes the detail marker's nodes for the given record; throws a DataException if buildHeader(JsonGenerator) found no detail marker.
      Throws:
      IOException
    • buildFooter

      public void buildFooter(com.fasterxml.jackson.core.JsonGenerator jsonGenerator) throws IOException
      Writes the nodes after the detail marker, closing the objects and arrays the header opened.
      Throws:
      IOException
    • object

      public JsonObject object()
      Description copied from class: JsonNode
      Adds an anonymous object element and returns it; only arrays (and the template root) accept one.
      Overrides:
      object in class JsonNode
    • array

      public JsonArray array()
      Description copied from class: JsonNode
      Adds an anonymous array element and returns it; only arrays (and the template root) accept one.
      Overrides:
      array in class JsonNode