#json #convert #string #serde-json #value #vec-string #object-like

mavec

Converts an object-like json into a String vector

4 releases

new 0.2.1 Feb 13, 2025
0.1.3 Jan 6, 2025
0.1.2 Jan 6, 2025
0.1.1 Jan 6, 2025
0.1.0 Jan 6, 2025

#1797 in Encoding

Download history 154/week @ 2024-12-31 109/week @ 2025-01-07 2/week @ 2025-02-04 157/week @ 2025-02-11

159 downloads per month

MIT/Apache

7KB

Mavec

Latest Version

mavec is a lightweight Rust library designed for transforming and handling Values data with ease. It provides utilities for converting Json-like objects into flattened Vec<String> representations, enabling seamless integration with applications that require efficient data processing, such as CLI tools, APIs, or data pipelines.

Getting started

add mavec to your dependencies in Cargo.toml:

[dependencies]
mavec = "0.1.2"

Usage

use mavec::core::to_vec;
use serde_json::json;

fn main() {
    let value = json!({
        "Jeff": true,
        "Rose": "Mary",
        "Miguel": 17,
    });
    
    assert_eq!(
        to_vec(value).unwrap(),
        Vec::from([
            "Jeff".to_string(),
            "true".to_string(),
            "Rose".to_string(),
            "Mary".to_string(),
            "Miguel".to_string(),
            "17".to_string()
        ])
    );

    let value = Value::Array(vec![
        json!(1),
        Value::Bool(true),
        Value::String(String::from("Mavec")),
        Value::Bool(false),
    ]);

    assert_eq!(
        to_vec(value).unwrap(),
        Vec::from([
            "1".to_string(),
            "true".to_string(),
            "Mavec".to_string(),
            "false".to_string(),
        ])
    );
}

Changelog

v1.2.1

Fixes

  • Adding documentation for new functionality

v1.2.0

Features

  • to_vec() now works not only for Value::Object but also with a Value::Array Value.

Contributing

Contributions are welcome! If you have ideas for new features or optimizations, feel free to open an issue or submit a pull request.

  • Fork the repository.
  • Create a new branch for your feature or bugfix.
  • Submit a pull request with a detailed explanation.

Dependencies

~1.4–2.4MB
~48K SLoC