Skip to contents

This function extracts the data from a seasonder_cs_object, representing a SeaSondeRCS object, and converts it into a JSON format. Optionally, it can write this JSON data to a specified file path.

Usage

seasonder_asJSONSeaSondeRCSData(seasonder_cs_object, path = NULL)

Arguments

seasonder_cs_object

A SeaSondeRCS object from which the data will be extracted.

path

Optional path to a file where the JSON output should be saved. If provided, the function will write the JSON data to this file. If NULL, the function will only return the JSON data as a string without writing it to a file.

Value

A character string in JSON format representing the data of the provided SeaSondeRCS object. If a path is provided, the function also writes this data to the specified file.

Note

If a path is provided and there is an issue writing to the file, the function logs an error message using seasonder_logAndMessage and returns the JSON data as a string.

Examples

# Example: create a simple SeaSondeRCS object and convert its data to JSON
cs_obj <- structure(list(data = list(a = 1, b = 2)), class = "SeaSondeRCS")
json_output <- seasonder_asJSONSeaSondeRCSData(cs_obj)
print(json_output)
#> {
#>   "a": [1],
#>   "b": [2]
#> }