Expand description

libflatterer - Lib to make JSON flatterer.

Currently for use only for flatterer.

This is all an internal API exposed to the above tool, so fairly unstable for the time being as extra arguments could be added with minor version bump.

use tempfile::TempDir;
use std::fs::File;
use libflatterer::{FlatFiles, flatten};
use std::io::BufReader;

let tmp_dir = TempDir::new().unwrap();
let output_dir = tmp_dir.path().join("output");
let output_path = output_dir.to_string_lossy().into_owned();
let flat_files = FlatFiles::new(
    output_path, // output directory
    true, // output directory
    true, // make csv
    true, // make xlsx
    true, // make sqlite
    "main".to_string(), // main table name
    vec![], // list of json paths to omit object as if it was array
    false, // inline one to one tables if possible
    "".to_string(), // path or uri to JSONSchema
    "prefix_".to_string(), // table prefix
    "_".to_string(), // path seperator
    "".to_string(), // schema titles
).unwrap();

flatten(
   BufReader::new(File::open("fixtures/basic.json").unwrap()), // reader
   flat_files, // FlatFile instance.
   vec![],
   false); // Path to array.

Structs

Enums

Expreses a JSON path element, either a string or a number.

Functions