Package generalDatabase
Class JsonConverter
java.lang.Object
generalDatabase.JsonConverter
- Direct Known Subclasses:
ClassifierJSONLogging
,CTAlgorithmInfoLogging
,ErrorJsonConverter
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetJSONElement
(String name, double[] data) getJSONElement
(String name, double[] data, DecimalFormat format) Make a standard JSON like elementquickJsonString
(String name, double[] data) Function to create a complete json like string including start and end characters using a standard number format.double[]
unpackJsonArray
(com.fasterxml.jackson.databind.node.ArrayNode jsonArrayNode) void
writeJsonArray
(com.fasterxml.jackson.core.JsonGenerator jasonGenerator, String name, double[] data) Write an array of numbers into a JSON array in a predetermined number format.void
writeJsonValue
(com.fasterxml.jackson.core.JsonGenerator jasonGenerator, String name, double data) Write a single number into a JSON array in a predetermined number format.
-
Constructor Details
-
JsonConverter
public JsonConverter()
-
-
Method Details
-
getJSONElement
-
getJSONElement
Make a standard JSON like element- Parameters:
name
- name of elementdata
- data for itformat
- number format to use- Returns:
- String of formatted data.
-
unpackJsonArray
public double[] unpackJsonArray(com.fasterxml.jackson.databind.node.ArrayNode jsonArrayNode) -
quickJsonString
Function to create a complete json like string including start and end characters using a standard number format.- Parameters:
name
- name of itemdata
- 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
-