pub struct Json2Csv { /* private fields */ }
Expand description

Basic struct of this crate. It contains the configuration.Instantiate it and use the method convert_from_array or convert_from_file to convert the JSON input into a CSV file.

Implementations

Creates a JSON to CSV object with the flattening config provided.

Flattens each one of the objects in the array slice and transforms each of them into a CSV row.

The headers of the CSV are the union of all the keys that result from flattening the objects in the input.

Errors

Will return Err if objects does not contain actual JSON objects. It will also report an error if two objects have keys that should be different but end looking the same after flattening, and if writing the CSV fails.

Flattens the JSON objects in the file, transforming each of them into a CSV row.

The headers of the CSV are the union of all the keys that result from flattening the objects in the input. The file must contain JSON objects one immediately after the other or separated by whitespace. Note that it uses a temporary file to store the flattened input, which is automatically deleted when lo longer necessary.

Errors

Will return Err if parsing the file fails or if the JSONs there are not objects. It will also report an error if two objects have keys that should be different but end looking the same after flattening, and if writing the CSV or to the temporary file fails.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.