Class SpectrumJsonUtils


  • public class SpectrumJsonUtils
    extends Object
    For converting spectra to JSON and vice versa.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • SpectrumJsonUtils

        public SpectrumJsonUtils()
    • Method Detail

      • example

        public static String example​(boolean useRefAndMeta)
        Returns an example spectrum in JSON.
        Parameters:
        useRefAndMeta - whether to output example for ref/meta-data or complete report
        Returns:
        the example string
      • fromJson

        public static Spectrum fromJson​(com.google.gson.JsonObject jobj)
        Creates a spectrum from the JSON object (spectral + report).
        Parameters:
        jobj - the object to get the data from
        Returns:
        the spectrum, null if failed to create or find data
      • toJson

        public static com.google.gson.JsonObject toJson​(Spectrum spec)
        Turns the spectrum into a json structure (spectral + report).
        Parameters:
        spec - the spectrum to convert
        Returns:
        the json data structure
        See Also:
        KEY_AMPLITUDES, KEY_WAVES, KEY_REPORT
      • toJson

        public static com.google.gson.JsonObject toJson​(Spectrum spec,
                                                        adams.data.report.Field[] ref,
                                                        adams.data.report.Field[] meta)
        Turns the spectrum into a json structure (spectral + ref + meta).
        Parameters:
        spec - the spectrum to convert
        ref - the reference values to output
        meta - the meta-data values to output
        Returns:
        the json data structure
        See Also:
        KEY_AMPLITUDES, KEY_WAVES, KEY_REFERENCE, KEY_METADATA