Class JsonConverter

java.lang.Object
generalDatabase.JsonConverter
Direct Known Subclasses:
ClassifierJSONLogging, CTAlgorithmInfoLogging, ErrorJsonConverter

public class JsonConverter extends Object
Converts arrays of numbers into string representations which are a little bit, but not entirely json like for writing to text fields in the database.
Author:
Doug
  • Constructor Details

    • JsonConverter

      public JsonConverter()
  • Method Details

    • getJSONElement

      public String getJSONElement(String name, double[] data)
    • getJSONElement

      public String getJSONElement(String name, double[] data, DecimalFormat format)
      Make a standard JSON like element
      Parameters:
      name - name of element
      data - data for it
      format - number format to use
      Returns:
      String of formatted data.
    • unpackJsonArray

      public double[] unpackJsonArray(com.fasterxml.jackson.databind.node.ArrayNode jsonArrayNode)
    • quickJsonString

      public String quickJsonString(String name, double[] data)
      Function to create a complete json like string including start and end characters using a standard number format.
      Parameters:
      name - name of item
      data - array of data
      Returns:
      json string.
    • writeJsonArray

      public void writeJsonArray(com.fasterxml.jackson.core.JsonGenerator jasonGenerator, String name, double[] data) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
      Write an array of numbers into a JSON array in a predetermined number format. Can only be used for a single json element.
      Parameters:
      jasonGenerator -
      name -
      data -
      Throws:
      com.fasterxml.jackson.core.JsonGenerationException
      IOException
    • writeJsonValue

      public void writeJsonValue(com.fasterxml.jackson.core.JsonGenerator jasonGenerator, String name, double data) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
      Write a single number into a JSON array in a predetermined number format.
      Parameters:
      jasonGenerator -
      name -
      data -
      Throws:
      com.fasterxml.jackson.core.JsonGenerationException
      IOException